SQL必知必会 第五版 学习笔记6-

#predicate weici
-- tongbeifu zhineng shiyong yu wenben ziduan 
SELECT prod_id,prod_name
FROM  products
WHERE prod_name like 'fish%';
#
SELECT prod_id,prod_name
FROM products
WHERE prod_name like '%bag%';
#
SELECT prod_name,prod_id
FROM products
WHERE prod_name LIKE 'f%y';
#_ 通配符只能对应按个数对应,如一个下滑杠通配适用一个字符,两个则配两个
SELECT prod_name,prod_id
FROM products
WHERE prod_name LIKE '__ inch teddy bear'
#
SELECT prod_name,prod_id
FROM products
WHERE prod_name LIKE '%inch teddy bear'
#mysql 不支持方括号通配符
SELECT cust_contact
FROM customers
WHERE cust_contact LIKE '[JM]%'
ORDER BY cust_contact;
#6-1
SELECT prod_name,prod_desc
FROM products
WHERE prod_name LIKE '%toy%'
#6-2
SELECT prod_name,prod_desc
FROM products
WHERE NOT prod_name LIKE '%toy%'
ORDER BY prod_name
#6-3
SELECT prod_name,prod_desc
FROM products
WHERE prod_desc LIKE '%toy%' AND prod_desc LIKE '%carrots%';
#6-4
SELECT prod_name,prod_desc
FROM products
WHERE prod_desc LIKE '%toy%carrots%';
#lesson 7 concatenate
SELECT concat(vend_name, ' (',vend_country,')')
FROM Vendors
ORDER BY vend_name;

上一篇:淘宝商品上传API接口 (万邦专属)


下一篇:mfc动态控件生成