🗄️

SQL: Queries, Joins & Aggregates

74 cards · 🇺🇸 English

SELECT queries, joins, and aggregate functions in SQL.

Study all 74 cards for free

Flashcards, quizzes, pixel-art games and a daily review that remembers for you.

Study this deck free

Try the first 10 cards

1 / 10
Question

SQL

Knew itLearning

Tap the card for the answer · swipe right if you knew it, left if not

Already have an account? Sign in

Cards

  1. 1SQL
    Structured Query Language
  2. 2Is SQL case-sensitive?
    Keywords are not case-sensitive, but data may be (depends on DBMS and collation settings)
  3. 3Four main SQL sublanguages
    DQL (Data Query Language), DDL (Data Definition Language), DML (Data Manipulation Language), DCL (Data Control Language)
  4. 4SELECT statement
    A query used to retrieve data from one or more tables
  5. 5Syntax for a basic SELECT query
    SELECT column1, column2 FROM table_name;
  6. 6Select all columns from a table
    SELECT * FROM table_name;
  7. 7WHERE clause
    Filters rows based on specified conditions
  8. 8Syntax for WHERE
    SELECT * FROM table_name WHERE condition;
  9. 9What operators can be used in WHERE?
    =, !=, <, >, <=, >=, AND, OR, NOT, LIKE, IN, BETWEEN, IS NULL
  10. 10LIKE
    Pattern matching using wildcards (% for any characters, _ for single character)
  11. 11IN
    Checks if a value matches any value in a list: WHERE country IN ('USA', 'Canada')
  12. 12BETWEEN
    Selects values within a range (inclusive): WHERE age BETWEEN 20 AND 30
  13. 13NULL in SQL
    A marker indicating absence of value (not equal to 0 or empty string)
  14. 14Check for NULL values
    Use IS NULL or IS NOT NULL (not = NULL)
  15. 15Why can't you use = NULL?
    NULL represents unknown, and any comparison with NULL returns NULL (not true or false)
  16. 16ORDER BY
    Sorts query results by one or more columns
  17. 17Default order for ORDER BY
    ASC (ascending)
  18. 18Sort in descending order
    Use DESC: ORDER BY column_name DESC
  19. 19DISTINCT
    Removes duplicate rows from the result set
  20. 20Syntax for DISTINCT
    SELECT DISTINCT column_name FROM table_name;
  21. 21LIMIT
    Restricts the number of rows returned (syntax varies by DBMS: LIMIT in MySQL, TOP in SQL Server)
  22. 22INNER JOIN
    Returns only rows where there is a match in both tables
  23. 23Syntax for INNER JOIN
    SELECT * FROM table1 INNER JOIN table2 ON table1.id = table2.id;
  24. 24LEFT JOIN
    Returns all rows from the left table and matched rows from the right table (NULL for non-matches)
  25. 25LEFT JOIN vs LEFT OUTER JOIN
    They are the same - OUTER is optional
  26. 26RIGHT JOIN
    Returns all rows from the right table and matched rows from the left table (NULL for non-matches)
  27. 27FULL JOIN (FULL OUTER JOIN)
    Returns all rows when there is a match in either left or right table (NULL for non-matches on either side)
  28. 28CROSS JOIN
    Returns the Cartesian product of both tables (every row of table1 with every row of table2)
  29. 29Self-join
    Joining a table to itself (uses aliases to differentiate the same table)
  30. 30COUNT()
    Returns the number of rows that match a specified condition

And 44 more cards. Study the whole deck free

Articles about this deck

More Programming decks

See all
Study all 74 cards free