gpt4 book ai didi

sql - 根据字段开头的内容选择记录?

转载 作者:行者123 更新时间:2023-12-04 13:05:33 30 4
gpt4 key购买 nike

我有一个带有标识符 c1、c2、c3.. 等的表的数据库。

而不是编写一个包含一堆 OR 的查询在其中,如何修改以下查询以捕获以某个字母开头的所有记录?

SELECT 
Person.spineinjuryAdmit,
tblComorbidity.comorbidityexplanation,
Count(tblComorbidity.comorbidityexplanation) AS CountOfcomorbidityexplanation

FROM tblKentuckyCounties
INNER JOIN (tblComorbidity
INNER JOIN (Person
INNER JOIN tblComorbidityPerson
ON Person.PersonID = tblComorbidityPerson.personID)
ON tblComorbidity.ID = tblComorbidityPerson.comorbidityFK)
ON tblKentuckyCounties.ID = Person.County
GROUP BY Person.spineinjuryAdmit,
tblComorbidity.comorbidityexplanation
HAVING (((Person.spineinjuryAdmit)="c1" Or
(Person.spineinjuryAdmit)="c2" Or
(Person.spineinjuryAdmit)="c3"));

最佳答案

    SELECT Person.spineinjuryAdmit, tblComorbidity.comorbidityexplanation, Count(tblComorbidity.comorbidityexplanation) AS CountOfcomorbidityexplanation
FROM tblKentuckyCounties INNER JOIN (tblComorbidity INNER JOIN (Person INNER JOIN tblComorbidityPerson ON Person.PersonID = tblComorbidityPerson.personID) ON tblComorbidity.ID = tblComorbidityPerson.comorbidityFK) ON tblKentuckyCounties.ID = Person.County
GROUP BY Person.spineinjuryAdmit, tblComorbidity.comorbidityexplanation
HAVING (Person.spineinjuryAdmit LIKE "c*");

关于sql - 根据字段开头的内容选择记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6192499/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com