【问题标题】:sql query alphabetical initialssql查询字母缩写
【发布时间】:2015-04-12 18:01:33
【问题描述】:

我很难理解的问题是:

编写查询以列出以初始字母字符开头的成分数量。您的输出应该有

任何帮助将不胜感激!

 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;

【问题讨论】:

  • 您必须给我们一个课程学分才能帮助您完成家庭作业。

标签: jquery database oracle alphabetical


【解决方案1】:

我不确定我的表格是否正确 但这或多或少是您需要的(许多方法可以为您提供相同的解决方案):

 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

【讨论】:

  • 此解决方案缺少 ORDER BY 子句,因此无法保证“按字母顺序排列”。
猜你喜欢
  • 2017-01-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-04-09
  • 2013-09-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多