I learned the quick and dirty way, so I tend to do implicit joins with some fancy (or ugly, depending on your viewpoint) where clause stuff. Here's one I made earlier with 4 tables that gets all the units in the database that have a certain $datavalue. IDs are primary keys in their own table that also exist as fields in other tables, follow the pattern of the tables and IDs for the relationship between the tables (all names munged as they wouldn't mean anything outside my project anyway)...
SELECT field1, field2, field3, field4, FROM table1, table2, table3, table4 WHERE (table1.ID_1 = table2.ID_1) AND (table2.ID_2 = table3.ID_2) AND (table3.ID_3 = table4.ID_3) AND (table3.ID_4 = $data_value);
It works for me, if the more experienced SQLMonks say its bad, don't do it.
How can you feel when you're made of steel? I am made of steel. I am the Robot Tourist.
Robot Tourist, by Ten Benson
Edited: took out extraneous ' characters (my excuse is I pasted from Delphi, where you don't get automatic multiline strings)
In reply to Re: 2 mysql selects in one statement
by robot_tourist
in thread 2 mysql selects in one statement
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |