--1.查询出对应的<价格小于等于5的商品。
select vend_id,prod_id,prod_price
from products
where prod_price<=5;
--2.查询出对应的在1001和1002 对应的物品。
select vend_id,prod_id,prod_price
from products
where vend_id in(1001,1002);
从组合查询出对应的记录集合:
select vend_id,prod_id,prod_price
from products
where prod_price<=5
Union
select vend_id,prod_id,prod_price
from products
where vend_id in(1001,1002)
--这里给出相同的查询:
select vend_id,prod_id,prod_price
from products
where prod_price<=5 or vend_id in (1001,1002);
不取消重复的行使用:union all
select vend_id,prod_id,prod_price
from products
where prod_price<=5
Union all
select vend_id,prod_id,prod_price
from products
where vend_id in(1001,1002)
order by 子句只能放在后边:
select vend_id,prod_id,prod_price
from products
where prod_price<=5
Union all
select vend_id,prod_id,prod_price
from products
where vend_id in(1001,1002)
order by vend_id,prod_price
select vend_id,prod_id,prod_price
from products
where prod_price<=5
Union all
select vend_id,prod_id,prod_price
from products
where vend_id in(1001,1002)
order by vend_id,prod_price