Java教程

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;

这篇关于SQL必知必会 第五版 学习笔记6-的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!