我正在努力理解的问题是:
编写查询以列出以初始字母字符开头的成分数。您的输出应该有< = 26行并按字母顺序排序。
非常感谢任何帮助!
CREATE TABLE Ingredient
(
idI NUMBER constraint pk_Ingredient PRIMARY KEY ,
ingrDesc VARCHAR2(100) constraint nn1Ingredient not null
);
CREATE TABLE Recipe
(
idR NUMBER constraint pk_recipe PRIMARY KEY ,
recipeTitle VARCHAR2(200) constraint nn1Recipe not null,
prep Text VARCHAR2(4000),
cuisineType VARCHAR2(50),
mealType VARCHAR2(30) DEFAULT NULL,
CONSTRAINT ch_mealType CHECK (mealType IN ('starter', 'main', 'dessert', null))
);
CREATE TABLE RecpIngr
(
idR NUMBER ,
hidI NUMBER ,
CONSTRAINT pk_RecpIngr PRIMARY KEY (idR, idI),
CONSTRAINT fk1RecpIngr_recipe foreign key(idR) references Recipe,
CONSTRAINT fk2RecpIngr_ingredient foreign key(idI) references Ingredient
)
organization index;
答案 0 :(得分:0)
我不确定我的桌子是否正确 但这或多或少都是你需要的(很多方法可以给你相同的解决方案):
select * from
(
select distinct a.ingrDesc , b.recipeTitle
from Ingredient a,
Recipe b
RecpIngr c
where b.idR = b.idR
and a.idI = c.idR
)
where rownum <= 26
Order by ingrDesc