select
product.id
,detail.name
,product.price
-- 可以把区分code转换为名称
, (SELECT testFild from country where country.id = product.id) AS testFild
-- 当满足某些条件的时候才会进行查询
,CASE
WHEN product.price > 100 THEN
(select country from country where country.id = product.id)
ELSE '其他'
END country
from
product
left JOIN
detail
ON
product.id = detail.id
SQL中的子查询
最新推荐文章于 2024-03-28 18:33:18 发布