Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen gezeigt.

Link zu der Vergleichsansicht

Beide Seiten, vorherige Überarbeitung Vorherige Überarbeitung
Nächste Überarbeitung
Vorherige Überarbeitung
lf6:db-cheat-sheet [2018/10/24 13:38]
Marvin Birnbach
lf6:db-cheat-sheet [2018/10/24 13:41] (aktuell)
Marvin Birnbach
Zeile 1: Zeile 1:
 ====== SQL Cheat Sheet ====== ====== SQL Cheat Sheet ======
  
-| Description ​                                                                                                                     | Command ​                                                                                                                                                                                                                                                                                     |+**Description**                                                                                                                      ​| ​**Command**                                                                                                                                                                                                                                                                                      |
 | To login (from unix shell) use -h only if needed. ​                                                                               | [mysql dir]/​bin/​mysql -h hostname -u root -p                                                                                                                                                                                                                                                 | | To login (from unix shell) use -h only if needed. ​                                                                               | [mysql dir]/​bin/​mysql -h hostname -u root -p                                                                                                                                                                                                                                                 |
 | Create a database on the sql server. ​                                                                                            | create database [databasename]; ​                                                                                                                                                                                                                                                             | | Create a database on the sql server. ​                                                                                            | create database [databasename]; ​                                                                                                                                                                                                                                                             |
Zeile 16: Zeile 16:
 | Show all records not containing the name "​Bob"​ AND the phone number '​3444444'​ order by the phone_number field. ​                  | SELECT * FROM [table name] WHERE name != "​Bob"​ AND phone_number = '​3444444'​ order by phone_number; ​                                                                                                                                                                                          | | Show all records not containing the name "​Bob"​ AND the phone number '​3444444'​ order by the phone_number field. ​                  | SELECT * FROM [table name] WHERE name != "​Bob"​ AND phone_number = '​3444444'​ order by phone_number; ​                                                                                                                                                                                          |
 | Show all records starting with the letters '​bob'​ AND the phone number '​3444444'​. ​                                                | SELECT * FROM [table name] WHERE name like "​Bob%"​ AND phone_number = '​3444444'; ​                                                                                                                                                                                                             | | Show all records starting with the letters '​bob'​ AND the phone number '​3444444'​. ​                                                | SELECT * FROM [table name] WHERE name like "​Bob%"​ AND phone_number = '​3444444'; ​                                                                                                                                                                                                             |
-| Use a regular expression to find records. Use "​REGEXP BINARY"​ to force case-sensitivity. This finds any record beginning with a. | SELECT * FROM [table name] WHERE rec RLIKE "​^a$"; ​                                                                                                                                                                                                                                           | 
 | Show unique records. ​                                                                                                            | SELECT DISTINCT [column name] FROM [table name]; ​                                                                                                                                                                                                                                            | | Show unique records. ​                                                                                                            | SELECT DISTINCT [column name] FROM [table name]; ​                                                                                                                                                                                                                                            |
 | Show selected records sorted in an ascending (asc) or descending (desc). ​                                                        | SELECT [col1],​[col2] FROM [table name] ORDER BY [col2] DESC;                                                                                                                                                                                                                                 | | Show selected records sorted in an ascending (asc) or descending (desc). ​                                                        | SELECT [col1],​[col2] FROM [table name] ORDER BY [col2] DESC;                                                                                                                                                                                                                                 |
  • lf6/db-cheat-sheet.1540381112.txt.gz
  • Zuletzt geändert: 2018/10/24 13:38
  • von Marvin Birnbach