Skip to main content
AllScience
Tools
Home
Categories
Cheatsheets
Blog
About
Search tools...
Ctrl+K
Preparing your Lab
AllScienceTools
Home
Topics
Search
About
Basic Querying
Copy
SELECT
column1, column2
FROM
table_name
WHERE
condition
ORDER BY
column
ASC
|
DESC
;
Joins
INNER JOIN
Records with match in both tables
LEFT JOIN
All from Left, matched from Right
RIGHT JOIN
All from Right, matched from Left
FULL JOIN
Match in either table
Copy
SELECT
*
FROM
A
INNER JOIN
B
ON
A.id = B.a_id;
Aggregation
COUNT(*)
: Row count
SUM(col)
: Sum of values
AVG(col)
: Average
Copy
SELECT
city,
COUNT
(*)
FROM
users
GROUP BY
city
HAVING
COUNT
(*) > 5;
Modifying Data
Copy
INSERT INTO
table (c1, c2)
VALUES
(v1, v2);
Copy
UPDATE
table
SET
c1 = v1
WHERE
condition;
Copy
DELETE FROM
table
WHERE
condition;