Page 1 of 1

mysql table select php etc... (thanks).

Posted: Tue Apr 26, 2005 12:55 am
by technics
hey all. i have two tables that holds:

table1= A, B, C and a_id
table2= X, Y, Z and b_id


I want to select and align the record rows from table1 and table2 wherever a_id = b_id.

So i get to display:

A B C X Y Z wherever a_id in table1 is = b_id in table2

How do i write my SQL statement, and how do i retrieve the values!?! Thanks a mill guys (and girls).

Posted: Tue Apr 26, 2005 2:07 am
by timvw
time to read a basic sql tutorial|book|whatever?

Code: Select all

SELECT A, B, C, X, Y, Z
FROM table1, table2
WHERE table1.a_id=table2.b_id
or if you read a little more:

Code: Select all

SELECT A, B, C, X, Y, Z
FROM table1
INNER JOIN table2 USING a_id=b_id

Posted: Tue Apr 26, 2005 2:39 am
by technics
thanks mate