Data from two tables in one query, no join?

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
Smasher
Forum Commoner
Posts: 38
Joined: Fri Apr 20, 2007 5:22 am

Data from two tables in one query, no join?

Post by Smasher »

query("
SELECT c.id, g.id as Gid
FROM containment c
FROM geezer g
ORDER BY c.`order`, g.`order`");

Then ofcourse loop through them...is it possible without using a join? They aren't joined in anyway possible, but I need to retrieve there dataset in one.
Smasher
Forum Commoner
Posts: 38
Joined: Fri Apr 20, 2007 5:22 am

Post by Smasher »

CROSS JOIN.

Just for reference.
User avatar
Gente
Forum Contributor
Posts: 252
Joined: Wed Jun 13, 2007 9:43 am
Location: Ukraine, Kharkov
Contact:

Data size

Post by Gente »

And what about count of c.id and count of g.id. Are you sure they are equal? :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You're looking for a UNION.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Code: Select all

SELECT c.id, g.id as Gid FROM containment c, geezer g WHERE c.tkey=g.tkey ORDER BY c.`order`ASC, g.`order` ASC
Post Reply