Skip to content

Commit 28af451

Browse files
committed
Querying data from a table
1 parent dd7ac09 commit 28af451

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

mysql-queries.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,29 @@
1616
| 09. |LEFT JOIN |Returns all rows from the ‘left’ (1st) table with the matching rows in the right (2nd)|
1717
| 10. |RIGHT JOIN|Returns all rows from the ‘right’ (2nd) table with the matching rows in the left (1st)|
1818
| 11. |FULL OUTER JOIN|Returns rows that match either in the left or right table|
19+
20+
21+
#### Reporting Aggregate functions
22+
23+
In database management, an aggregate function is a function where the values of multiples rows are grouped to form a single value.
24+
25+
|Sl.No |Function | Description |
26+
|------|-----------|---------------------------------------------------|
27+
| 01. |COUNT |Return the number of rows in a certain table/view |
28+
| 02. |SUM |Accumulate the values|
29+
| 03. |AVG |Returns the average for a group of values|
30+
| 04. |MIN |Returns the smallest value of the group|
31+
| 05. |MAX |Returns the largest value of the group|
32+
33+
34+
#### Querying data from a table
35+
36+
|Sl.No |Query | Description |
37+
|------|-----------------|---------------------------------------------------|
38+
| 01. |SELECT c1 FROM t |Select data in column c1 from a table named t |
39+
| 02. |SELECT * FROM t |Select all rows and columns from a table named t |
40+
| 03. |SELECT c1 FROM t WHERE c1 = ‘test’|Select data in column c1 from a table named t where the value in c1 = ‘test’
41+
| 05. |SELECT c1 FROM t ORDER BY c1 ASC (DESC)|Select data in column c1 from a table name t and order by c1, either in ascending (default) or descending order |
42+
| 07. |SELECT c1 FROM t ORDER BY c1LIMIT n OFFSET offset|Select data in column c1 from a table named t and skip offset of rows and return the next n rows|
43+
| 08. |SELECT c1, aggregate(c2) FROM t GROUP BY c1|Select data in column c1 from a table named t and group rows using an aggregate function |
44+
| 09. |SELECT c1, aggregate(c2) FROM t GROUP BY c1 HAVING condition|Select data in column c1 from a table named t and group rows using an aggregate function and filter these groups using ‘HAVING’ clause|

0 commit comments

Comments
 (0)