Course Content
Introduction to SQL
Introduction to SQL
2. Filtering Data
The WHERE ClauseChallenge: Help a Reader Find Their Favorite GenreChallenge: Fetching Older BooksConditional Expressions: Comparison OperatorsChallenge: Avoid the Damaged BooksChallenge: Highlight New ArrivalsChallenge: Budget-Friendly BooksConditional Expressions: The AND OperatorChallenge: Find Specific Books for a ReaderChallenge: Defining RangesChallenge: Multiple ConditionsConditional Expressions: The OR OperatorChallenge: Matching Multiple OptionsChallenge: Excluding A RangeConditional Expressions: The NOT OperatorChallenge: Negating a Range
3. Sorting Data
Basic SortingChallenge: Sorting the Library CatalogueSorting by Multiple ColumnsChallenge: Further Sorting the CatalogueSorting after Filtering DataChallenge: Find the Cheapest BooksChallenge: Help a Customer Find a BookThe LIMIT KeywordChallenge: Select Books for the Collector's SectionChallenge: Affordable Books
4. Populating a Database
Creating a TableChallenge: Creating a new Books TableInserting Rows into a TableChallenge: Inserting DataChallenge: Inserting More DataInserting Multiple RowsChallenge: Inserting Bulk DataPrimary KeysThe SERIAL KeywordChallenge: Changing the Books StructureSpecifying Default ValuesChallenge: Further Improving the Books Table
5. Updating & Deleting Data
Inserting Multiple Rows
Oftentimes we need to insert more than one row into a table, and re-writing the insert statements many times can be tedious and inefficient. Luckily, SQL provides us with a slightly shorter syntax which basically compresses multiple INSERT
statements into a single query.
Following is the general syntax for inserting multiple rows using a single insert statement:
The following example shows the syntax for inserting multiple rows into a table called students
which has three columns first_name
, second_name
and age
:
INSERT INTO students (first_name, second_name, age) VALUES ('Alice', 'Smith', 20), ('Bob', 'Johnson', 22), ('Charlie', 'Brown', 19); SELECT * FROM students;
Tip:
This syntax has a shorter version as well, in which we don't specify the column names:
In this case the query will look like this:
Demonstration:
Everything was clear?
Thanks for your feedback!
Section 4. Chapter 6