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

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
technics
Forum Newbie
Posts: 16
Joined: Sun Feb 13, 2005 6:50 pm

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

Post 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).
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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
technics
Forum Newbie
Posts: 16
Joined: Sun Feb 13, 2005 6:50 pm

Post by technics »

thanks mate
Post Reply