I can't seem to get the data I want from my tables.
Desired result is: recipe_ingredient (from recipe_ingredient ) paired with its corresponding prep instruction from 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 R, prep P, menu_item M
INNER JOIN recipe_ingredient ri ON mi.menu_item_id = ri.menu_item_id
INNER JOIN prep pr ON mi.menu_item_id = pr.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;
Desired result is: recipe_ingredient (from recipe_ingredient ) paired with its corresponding prep instruction from 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 R, prep P, menu_item M
INNER JOIN recipe_ingredient ri ON mi.menu_item_id = ri.menu_item_id
INNER JOIN prep pr ON mi.menu_item_id = pr.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;