1. The simplest single-condition query, where specifies the query conditions.
Select messagetype, messagename from t_sr_message where messagename = 'manage'
The following lists several query conditions, not all:
2. query groups
Select superno, typename from t_sr_messagetype group by superno, typename having typename <'20140901'
// Records of the superno and typenamecolumns are returned Based on the superno and typename groups, and the condition typename <200 must be met.
3. Sort query select * From t_sr_messagetype order by DESC
Order by can specify how the query results are sorted. Desc indicates reverse order, ASC indicates order
4. Convert and query the select userid user number, username user name, And userpwd user password from userinfo
The query result is as follows:
User ID |
User Name |
User Password |
1 |
Sword |
123456 |
2 |
Niuniu |
654321 |
5. Calculate and query select logincount + exitcount from userinfo
6. Equivalent multi-Table query
An equivalent multi-Table query queries the associated data of multiple data tables according to the equivalent conditions. Some fields of the associated data tables must have the same data type, width, and value range: select. name, B. typename from a, B where. id = B. ID
Query records with the same IDS as those in table B.
Non-equivalent multi-table queries are similar.
7. A nested query with 'in': select news. newtitle from news where news. userid in (select userid from userinfo where
Username <> 'sword ')
Query records of the newtitle field in the news table
The query results must meet the following conditions: first, query all the userids whose username is not the same as 'sword' in the userinfo table, and then obtain all the news of the userid in the previous userid in the news table. newtitle record.