sql-select Flashcards
What is SQL and how is it different from languages like JavaScript?
SQL is the primary way of interacting with relational databases. It is a powerful way of retrieving, creating, and manipulating data in a relational database. Unlike JS which is an imperative language, SQL is a declarative language. In declarative languages, 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 keyword ‘select’ followed by a comma separated list of column names in double quotes. Use the keyword ‘from’ and type table name in double quotes. Always end with semi colon
How do you filter rows based on some specific criteria?
‘where’
What are the benefits of formatting your SQL?
It is just orderly. For readability.
What are the four comparison operators that can be used in a ‘where’ clause?
The value of the ‘category’ column is being compared using a single = equals sign. (Other comparisons like , !, and = are available too)
How do you limit the number of rows returned in a result set?
Use the ‘limit’ clause
How do you retrieve all columns from a database table?
Use an asterisk *
How do you control the sort order of a result set?
You can do ‘order by’