Created
October 16, 2019 03:29
-
-
Save abue-ammar/2d23ca1ddc21b672860c890c53cd91fd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| MySQL consists of two parts. | |
| 1. DDL = Data Definition Language | |
| 2. DML = Data Manipulation Language | |
| */ | |
| -- DML Query 1(Inserting data) | |
| INSERT INTO tablename[(jcol1, col2, col3, ... ...)] VALUES(val1, val2, val3, ... ...); | |
| -- DML Query 2(Deleting data) | |
| DELETE FROM tablename | |
| WHERE condition; | |
| -- DML Query 3(Updating data) | |
| UPDATE tablename | |
| SET col1=val1, col2=val2, ... ... | |
| WHERE condition; | |
| --DML Query 4(Searching table data) | |
| -- 4.1>> to show the whole table data | |
| SELECT * | |
| FROM tablename; | |
| -- 4.2>> row filter(all column) | |
| SELECT * | |
| FROM tablename | |
| WHERE condition; | |
| -- 4.3>> column filter | |
| SELECT col1, col2*5, col3+col4, function(col5), ... ... ... | |
| FROM tablename | |
| [WHERE condition]; | |
| -- 4.4>> sorting table rows/data | |
| SELECT *|col1, col2*5, col3+col4, function(col5), ... ... ... | |
| FROM tablename | |
| [WHERE condition] | |
| ORDER BY col1 [ASC|DESC], col2 [ASC|DESC], ... ...; | |
| -- 4.5>> showing distinct data/removing duplicate data | |
| SELECT [DISTINCT] col1, col2*5, col3+col4, function(col5), ... ... ... | |
| FROM tablename | |
| [WHERE condition] | |
| [ORDER BY col1 [ASC|DESC], col2 [ASC|DESC], ... ...] | |
| -- 4.6>> column aliasing (can be used in GROUP BY, ORDER BY, HAVING clauses) | |
| SELECT [DISTINCT] col1, col2*5 AS 'newcol2', col3+col4 AS 'newcol3', function(col5) AS 'newcol4', ... ... ... | |
| FROM tablename | |
| [WHERE condition] | |
| [ORDER BY col1 [ASC|DESC], col2 [ASC|DESC], ... ... ]; | |
| -- 4.7>> limiting no. of rows | |
| -- default LIMIT 0, total_row_count | |
| SELECT [DISTINCT] col1, col2*5 [AS 'newcol2'], col3+col4 [AS 'newcol3'], function(col5) [AS 'newcol4'], ... ... ... | |
| FROM tablename | |
| [WHERE condition] | |
| [ORDER BY col1 [ASC|DESC], col2 [ASC|DESC], ... ... ] | |
| LIMIT [offset,] rowcount; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment