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
mysql join
Moderator: General Moderators
-
SidewinderX
- Forum Contributor
- Posts: 407
- Joined: Fri Jul 16, 2004 9:04 pm
- Location: NY
- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: mysql join
What are the foreign keys in each table? id? but what about the third table?
Going to need some more info to help
Going to need some more info to help
- EverLearning
- Forum Contributor
- Posts: 282
- Joined: Sat Feb 23, 2008 3:49 am
- Location: Niš, Serbia
Re: mysql join
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?