Page 1 of 1

mysql join

Posted: Sat Aug 02, 2008 6:30 pm
by SidewinderX
I have three queries which I would like to consolidate into one. I know I need to use JOIN, and I have done some research, but I am still not quite sure. Below are my thee pseudo queries, can someone help consolidate them into one?

$pid = SELECT `id` FROM `widget_layer` WHERE `name` = $position
$mid = SELECT `id` FROM `modules` WHERE `name` = $module AND `enabled` = 1
$result = SELECT `pid` FROM `relation` WHERE `pid` = $pid AND `mid` = $mid

Thanks,
John

Re: mysql join

Posted: Sat Aug 02, 2008 7:04 pm
by jaoudestudios
What are the foreign keys in each table? id? but what about the third table?

Going to need some more info to help

Re: mysql join

Posted: Sat Aug 02, 2008 8:33 pm
by EverLearning
How are those three tables related? I'm guessing that the 'mid' in the 'relation' table is module id from 'modules' tables? Also, what data exactly would you like to select?