sql-select Flashcards
What is SQL and how is it different from languages like JavaScript?
- Structured Query Language (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.
- SQL is a declarative programming language, meaning you describe the results you want and the programming environment comes up with its plan for getting those result.
- while JavaScript is an imperative programming language, meaning that you have to tell JavaScript what to do and how to do it.
How do you retrieve specific columns from a database table?
select keyword and followed by column name surrounded by double quotes
How do you filter rows based on some specific criteria?
where clause and followed by column name surrounded by double quotes , equal sign, and values wrapped in single quotes.
What are the benefits of formatting your SQL?
for consistent style and better readability.
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?
limit clause followed by an integer number
How do you retrieve all columns from a database table?
select * (asterisk)
How do you control the sort order of a result set?
order by clause, followed by a column name in double quotes, the default sort order is ascending order, or you can add desc keyword to switch to descending order.