SQL문 기초연습(1)

keymu·2024년 9월 26일
0

Select query with constraints

SELECT column, another_column,FROM mytable
WHERE condition
    AND/OR another_condition
    AND/OR;


Select query with unique results

SELECT DISTINCT column, another_column,FROM mytable
WHERE condition(s);

Select query with ordered results

SELECT column, another_column,FROM mytable
WHERE condition(s)
ORDER BY column ASC/DESC;

Select query with limited rows

SELECT column, another_column,FROM mytable
WHERE condition(s)
ORDER BY column ASC/DESC
LIMIT num_limit OFFSET num_offset;

Select query with INNER JOIN on multiple tables

SELECT column, another_table_column,FROM mytable
INNER JOIN another_table 
    ON mytable.id = another_table.id
WHERE condition(s)
ORDER BY column,ASC/DESC
LIMIT num_limit OFFSET num_offset;

Select query with LEFT/RIGHT/FULL JOINs on multiple tables

SELECT column, another_column,FROM mytable
INNER/LEFT/RIGHT/FULL JOIN another_table 
    ON mytable.id = another_table.matching_id
WHERE condition(s)
ORDER BY column,ASC/DESC
LIMIT num_limit OFFSET num_offset;

Select query with constraints on NULL values

SELECT column, another_column,FROM mytable
WHERE column IS/IS NOT NULL
AND/OR another_condition
AND/OR;
profile
Junior Backend Developer

0개의 댓글