in 查询
select * from{table}
where {列名} in ({列名的值的集合})
测试表:
测试语句:
select hprice,hName,hId,hType
from pc.dbo.hardware
where hId in (1,2,3)
效果:
like查询:
select * from{table}
where {列名} like {带有他通配符的字符}
测试表:
测试语句:
select hprice,hName,hId,hType
from pc.dbo.hardware
where hName like '华硕%'
效果:
with的使用:
从一段查询语句的结果中进行查询
with {别名} as({查询语句}) --这个{别名}相当于as后的查询语句的结果临时表,可用于二次查询,增加sql可读性--
select *
from {别名}
where {条件语句}
测试表:
测试语句:
with queryID as(select hprice,hName,hId,hType
from pc.dbo.hardware
where hId >2)
select *
from queryID
where hName='ql3x'
效果: