Select *from db_user where User_type in (5,8); select *from Db_user where User_type between (5,8); select *from Db_user where User_name like '%s% '; <span style= "font-family:arial, Helvetica, Sans-serif;" > where "%" can match one or more characters </span>select *from Db_user where user_name like ' _3_ '; <span style= "font-family:arial, Helvetica, Sans-serif; " > "_" matches one character </span>select *from db_user where user_name=a or password=3;//or keyword, match one on the line
Select *from db_user ORDER by id DESC;
<span style= "font-family:arial, Helvetica, Sans-serif;" ></span><pre name= "code" class= "SQL" >select *from db_user order by ID asc;//Ascending
Select Id,user_name,password GROUP BY user_type;//displays only one record per group
Select *from db_user ORDER by ID ASC limit 3;//limit display only three records
select *from db_user ORDER by ID ASC limit. From the beginning of the numbering, query two records
<p>select Count (*) from db_user;//shows the number of all rows </p><p>select *from user_name, user_type from Tp_user,db_ User here Tp_user.id = db_user.id;//Connection query, connect two tables </p><p>select *from Tp_user where user_name in (select User_ name from Db_user);//query Tp_user the same record as Db_user user_name </p><p>select *from tp_user where Money >= ( Select money from Db_user where id=1);//comparison operator query mode </p><p>select *from tp_user where user_name like '%php% ';// Query for records containing PHP fields </p><p>select max (score) from tp_user;//query Socre highest record </p><p>select *from Tp_user Where Money<any (select money from Db_user);//query money is less than all Db_user records, where the parentheses are called inner query, outside of the outer call query </p><p>< Span style= "font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " >select *from tp_user where Money>all (select money from Db_user);//money is greater than all db_user</span></p>< P><span style= "Font-family:monospace; White-space:pre; Background-color:rgb (240, 240, 240); " >select user_name from Tp_user UNION Select user_name from db_user;//merge duplicate user_name</span></p><p> <span style= "Font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " ><span style= "Font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " >select user_name from Tp_user UNION all select user_name from db_user;//list all results, do not merge </span></span></p ><p>//Regular Expression </p><p>select books from Tp_book where books REGEXP ' ^php '//^ matches records beginning with a specific beginning or string </p ><p><span style= "Font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " >select books from Tp_book where books REGEXP ' php$ ';//$ matches records with a specific end </span></p><p><span style= " Font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " ><span style= "Font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " >select books from Tp_book where Books REGEXP '. P ';//. Match the character set and any one of the characters, including line break and carriage return </span></span></p><p><span style= " Font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " ><span style= "Font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " ><span style= "Font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " >select books from Tp_book where Books REGEXP ' [PCA] ';//[PCA] matches records containing PCA </span></span></span>< /p><p><span style= "Font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " >select books from Tp_book where Books REGEXP ' [^c-z] ';//[^] matches any character except the character set </span></p><p>< Span style= "font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " ><span style= "Font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " >select books from Tp_book where books REGEXP ' php|java|c# ';//| equals or matches any stringLt;/span></span></p><p><span style= "Font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " ><span style= "Font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " ><span style= "Font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " >select books from Tp_book where books REGEXP ' j*a ';//Match a preceded by a J character record, * can represent 0 </span></span></span ></p><p><span style= "Font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " ><span style= "Font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " ><span style= "Font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " ><span style= "Font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " >select books from Tp_book where books REGEXP ' j+a ';//a record of at least one J before match A, + at least 1 </span></span></span ></spAn></p><p><span style= "Font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " ><span style= "Font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " ><span style= "Font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " ><span style= "Font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " ><span style= "Font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " >select books from Tp_book where Books REGEXP ' a{3} ';//Match a appears at least three records </span></span></span></ Span></span></p><p><span style= "Font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " >select books from Tp_book where Books REGEXP ' a{2,4};//matches a character at least 2 occurrences of up to 4 records </span></p><p>< Span style= "font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " ><span style= "foNt-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " ><span style= "Font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " ><span style= "Font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " ><span style= "Font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " ></span></span></span></span></span></p><p><span style= " Font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " ><span style= "Font-family:monospace; White-space:pre; BACKGROUND-COLOR:RGB (240, 240, 240); " ></span></span></p>
</pre><pre>
MySQL Common statements