Basic syntax structure for queries:
Select Column name/* from table name [where restriction] [order by order]
1. Query all rows and columns:
SELECT * FROM table name
2, Query department branches and columns: (Some columns use commas, to limit, some lines use where conditions to limit)
Select Column Name 1, column name 2 from table name where restriction condition
3. Use the alias of the column in the query:
Use as, use = (assign values from right to left), use spaces
4. Query null value is NULL
5, Sort: ASC Ascending, desc descending
Example:
Select from where username like ' li% '-- selects all users in the UserInfo table username with Lee start Selectfromwhere payway<> ' Online Banking '--select userinfo form Payway payment method is not equal to "online banking" userid, Usern, payway three columns
userid as User ID, username =username, phone call from UserInfo where username like ' Zhang% '
--Using aliases
SELECT * from userinfo where email is null
--Using IS null
Email is null or email= '
--is null: Never entered data
--": entered data, then deleted
SQL Server Learning Notes (Fri)--Query