sql-select Flashcards
What is SQL and how is it different from languages like JavaScript?
SQL (Structured Query Language) is the primary way of interacting with relational databases. It can be used to retrieve, create, and manipulate data in a relational database. SQL is different from languages like JavaScript in that it is a declarative programming language. Programmers describe the results they want and the programming environment comes up with its own plan for getting those results.
How do you retrieve specific columns from a database table?
Use the ‘select’ keyword followed by the name of the column
How do you filter rows based on some specific criteria?
Use the ‘where’ clause followed by a category name and a comparison (string in single quotes; numbers/booleans no quotes)
What are the benefits of formatting your SQL?
Formatting makes it easier to read and debug
What are four comparison operators that can be used in a where clause?
=, <, >, !=
How do you limit the number of rows returned in a result set?
Use the ‘limit’ clause followed by the integer number (with no quotes) you want to limit it to
How do you retrieve all columns from a database table?
select *
How do you control the sort order of a result set?
Use the ‘order by’ clause followed by a column name (in double quotes), can also add ‘desc’ (default is ascending)