Re: SELECT FROM 2 or more tables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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







--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux