phpPete
03-09-02, 14:04
| I can't seem to get the data I want from my tables. Desired result is: recipe_ingredient (from recipe_ingredient ) and instructions ( from prep ) I've tried any number of combinations of JOINS, the closest I get to what I want is using this JOIN: SELECT A.recipe_ingredient AS Ingredient, B.instruction AS 'Prep Note' FROM recipe_ingredient A, prep B LEFT JOIN menu_item M USING ( menu_item_id ) WHERE M.menu_item_name = ' Some Name ' GROUP BY A.recipe_ingredient **This gives me the correct ingredients, however, not the corresponding prep instruction for that ingredient's DB value. HELP, I'm GOING CRAZY!!! Thanks, Pete The structure is: # # Table structure for table `menu_item` # CREATE TABLE menu_item ( mid int(11) NOT NULL auto_increment, menu_item_id varchar(11) NOT NULL default '', recipe_id varchar(11) NOT NULL default '0', menu_item_name varchar(35) NOT NULL default '', PRIMARY KEY (mid) ) TYPE=MyISAM; # -------------------------------------------------------- # # Table structure for table `prep` # CREATE TABLE prep ( prep_id int(4) NOT NULL auto_increment, menu_item_id varchar(11) NOT NULL default '', instruction varchar(50) NOT NULL default '', recipe_id varchar(11) NOT NULL default '', PRIMARY KEY (prep_id) ) TYPE=MyISAM; # -------------------------------------------------------- # # Table structure for table `recipe_ingredient` # CREATE TABLE recipe_ingredient ( recipe_ingredient_id int(11) NOT NULL auto_increment, recipe_ingredient varchar(35) NOT NULL default '', menu_item_id varchar(11) NOT NULL default '', ingredient_id int(4) NOT NULL default '0', recipe_id varchar(11) NOT NULL default '', PRIMARY KEY (recipe_ingredient_id) ) TYPE=MyISAM; ----------------------------------------------------- |