gpt4 book ai didi

mysql - 如何组合两个 select 和两个 where 子句?

转载 作者:行者123 更新时间:2023-11-29 05:48:45 25 4
gpt4 key购买 nike

表一:

StudentId,  StudentName,  School
1 Sam ABC

表二:

StudentCity  StudentId
Paris 1
mexico 2

答案应该是“巴黎”,因为 StudentId 是 1

select StudentCity 
from TWO
where StudentId = (select StudentId from ONE where StudentName="SAM");

请给我建议 sql 查询。

最佳答案

select StudentCity from TWO 
inner join ONE on ONE.StudentId = TWO.StudentId
where ONE.StudentName= "SAM"

关于mysql - 如何组合两个 select 和两个 where 子句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56859798/

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