mysql join

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
SidewinderX
Forum Contributor
Posts: 407
Joined: Fri Jul 16, 2004 9:04 pm
Location: NY

mysql join

Post 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
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: mysql join

Post 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
User avatar
EverLearning
Forum Contributor
Posts: 282
Joined: Sat Feb 23, 2008 3:49 am
Location: Niš, Serbia

Re: mysql join

Post 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?
Post Reply