Re: SELECT FROM 2 or more tables

From: Date: Wed, 20 Aug 2003 19:53:22 +0000
Subject: Re: SELECT FROM 2 or more tables
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-29999@lists.php.net to get a copy of this message
John, It sounds like you need to read basic documentation on combining SQL queries. Basically, you need to have a column that is common across both tables. Eg., in TABLE1 have a column named TABLE1ID. Have the same ID cross referenced in TABLE2. The ID would be sequenced in some way (auto_increment if MySQL). So it would look like this: create table1 ( table1id number, data varchar); create table2 ( table2id number, table1id number, data varchar); select * from table1, table2, where table1.table1id = X and table1.table1id = table2.table1id; If that's still confusing, I suggest you take a look at the massive amount of documentation available on this subject on the web. http://www.mysql.com/doc/en is a good place to start. It's not necessary to use the complicated LEFT JOIN, INNER JOIN, etc, at first (until you have some pretty complicated queries). I hope this helps! - B. John Ryan wrote:
Is it easy?? Is it possible?? Should I just run 2 different queries and output their results in the PHP script and make it look like it's all from the same table I cant grasp JOIN for the life of me


« previous php.db (#29999) next »