数据库
首页 > 数据库> > SQL必知必会 第五版 学习笔记6-

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;

标签:prod,name,必知,products,SQL,第五版,WHERE,SELECT,LIKE
来源: https://blog.csdn.net/study_history/article/details/120970222