PDA

View Full Version : Calling up a records using a colum from another tb


tomlewis
12-17-2005, 04:12 PM
I have a table with a list of teams, each with their own ID.

If I fill in another colum in a table with their ID, how would I then connect the both tables to show the club I want, using the other table?

davidj
12-19-2005, 08:41 AM
are you using access or mysql ??

tomlewis
12-19-2005, 04:07 PM
MySQL.

davidj
12-19-2005, 04:37 PM
if you are using PHP to retrieve your data then your recordset should look like this

"SELECT * FROM table1 left join table2 on table2.field2 = table1.field1 WHERE field1!='123' and field2 ='1' and field1= '0' and field2 !='4' order by field2"

once you use a valid join with your SQL you can then target any field from your WHERE clause

start by just doing a simple...

"SELECT * FROM table1 left join table2 on table2.field2 = table1.field1

then run it to see if you get both tables back (joined together) then add your WHERE clause

tomlewis
12-20-2005, 11:23 AM
Is it possible to do multiple joins in the same recordset?

davidj
12-20-2005, 11:55 AM
yes you can join as many tables as you like as long as each table has a relationship

"SELECT * FROM table1 left join table2 on table2.field2 = table1.field1 left join table3 on table3.field3 = table1.field5 WHERE bla bla bla...

tomlewis
12-20-2005, 12:10 PM
yes you can join as many tables as you like as long as each table has a relationship

"SELECT * FROM table1 left join table2 on table2.field2 = table1.field1 left join table3 on table3.field3 = table1.field5 WHERE bla bla bla...
One final question - what about linking different fields from same tables/

THanks.

davidj
12-20-2005, 12:19 PM
i dont understand the question

if the fields are in the same table then they are already linked