School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,096 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,029 people online right now. Registration is fast and FREE... Join Now!




linking tables

 

linking tables

peter yianni

17 Jun, 2009 - 10:57 AM
Post #1

D.I.C Regular
***

Joined: 4 Jun, 2009
Posts: 308



Thanked: 2 times
My Contributions
ok heres what i have
i have my database set up
and i need to link several tables to
which need to be autofilled when somehits a create button
i have the generator to autofill the vales but i need to somhow get that linked with the createbuton
which then has to send the details to mysql to be saved then has to resend the same details that where just created to a page where the user that just hit the create button will have as theres

am i making sence here because im giving myself a headache just thinking about it lol



User is offlineProfile CardPM
+Quote Post


CamoDeveloper

RE: Linking Tables

17 Jun, 2009 - 03:41 PM
Post #2

D.I.C Head
Group Icon

Joined: 12 Jun, 2009
Posts: 204



Thanked: 12 times
Dream Kudos: 200
My Contributions
What language are you using for the front end?

Also, what version of MySQL are you running? If you can support Stored Procedures (Routines) then make one that creates a table and submits the data to a specified table you have setup already. Then, create another Stored Procedure to withdraw the data from that table and post it to where you want it.

Did that make any sense?

~Camo
User is offlineProfile CardPM
+Quote Post

peter yianni

RE: Linking Tables

17 Jun, 2009 - 04:03 PM
Post #3

D.I.C Regular
***

Joined: 4 Jun, 2009
Posts: 308



Thanked: 2 times
My Contributions
QUOTE(CamoDeveloper @ 17 Jun, 2009 - 03:41 PM) *

What language are you using for the front end?

Also, what version of MySQL are you running? If you can support Stored Procedures (Routines) then make one that creates a table and submits the data to a specified table you have setup already. Then, create another Stored Procedure to withdraw the data from that table and post it to where you want it.

Did that make any sense?

~Camo


ok let me show u

SELECT *
FROM users, horse_stats, jocky_stats
WHERE users.stable_name = jocky_stats.stable_name= horse_stats. stable_name = users.user_name

ok i am geting them up but getting to many results like its shown the stable name three times i want to join so it just shows the stable name with there horses and jocks

ok i am using dreamweaver cs4

This post has been edited by peter yianni: 17 Jun, 2009 - 04:07 PM
User is offlineProfile CardPM
+Quote Post

CamoDeveloper

RE: Linking Tables

17 Jun, 2009 - 08:29 PM
Post #4

D.I.C Head
Group Icon

Joined: 12 Jun, 2009
Posts: 204



Thanked: 12 times
Dream Kudos: 200
My Contributions
With that statement you're telling the database to return those values from all the tables separately. You need to join them together using the stable_name column. You may need to adjust this a little depending on the results you get. This is what it should look like :
CODE

-- I usually add styling to my statements for easier reading
SELECT
    *
FROM
    -- I made users the primary table, but you could make any of these the primary
    users
    -- I'm joining them on the common column name stable_name. To join tables they need to have a column that both tables use so the database can use it as a checking point
    LEFT JOIN horse_stats ON users.stable_name = horse_stats.stable_name
    LEFT JOIN jocky_stats ON users.stable_name = jocky_stats.stable_name
    -- You might need to change LEFT to either RIGHT or INNER depending on the results you recieve. LEFT should work just fine
WHERE
    -- Only selects the data that matches
    users.stable_name = horse_stats.stable_name
    AND users.stable_name = jocky_stats.stable_name
-- The entire WHERE can be removed if you want, it just helps with grabbing certain data


Let me know if you get any errors or have any more questions.

~Camo
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 11:56AM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month