1. Like
For example, we need to find all the articles containing the word "MySQL" from the titles of many articles. This should be used in the WHERE clause "like", that is, fuzzy query.
First, let's talk about the unified character in the SQL language. The unified character is to match any character in a single way. In SQL, a character "_" matches any character in a single character; one character "%" matches any zero to multiple characters. For example, "A _" can match "AA", "AB", "A2", and "A $ "...... "A %" matches "ABCD", "A", "AG $ bng0", and "An apple is just an apple ."...... And so on.
How to use it? Let's take a practical example: there are a lot of things in the factory warehouse and they are very complicated. They should be managed in several categories: for example, Class A represents Machine Accessories and Class B represents tools, class C represents packaging materials ...... And so on. The numbers in the following categories are numbered separately, such as "a0001", "a1065", and "b1014. When you manage this database, the number is used as a field. This field is used not only as the item code, but also as its category. When you want to query all the tools, you can:
Select * from goods where code like 'B % 'order by Code'
In this way, all records whose names start with the letter B are queried. Note that 'B %' indicates that the letter B appears at the beginning of the field. Different from the next example, you can find all the articles in the article title that contain the word "MySQL, because the target MySQL does not determine the position of the article title, you should:
Select * from articles where title like '% MySQL %'
'% MySQL %' indicates that the word "MySQL" appears in the title. It may be preceded by text or followed by text.
[Transfer] http://www.jscode.cn/develop/database/v34786
In addition: http://hi.baidu.com/cha369/item/12ac7e5a1e4e1c3d32e0a905
2. In where, or and
A = 3, B = 3, C = 3,
But it must be m = 1.
Where (A = 3 or B = 3 or C = 3) and M = 1
3. Order
Order by keyword classification by keywords
MySQL order by syntax
Select column_name (s)
From table_name
Order by column_name