SQL Queries
SQL Queries
2. If you are adding values for all the columns of the table, you do not need to
specify the column names in the SQL query. However, make sure the order of
the values is in the same order as the columns in the table. Here, the INSERT
INTO syntax would be as follows:
The following SQL statement will insert a new record, but only insert data in the
"CustomerName", "City", and "Country" columns (CustomerID will be updated
automatically)
To insert multiple rows of data, we use the same INSERT INTO statement, but
with multiple values:
Example:
VALUES
SQL SELECT
The SQL SELECT statement is used to select (retrieve) data from a
database table.
Syntax:
Example:
Select All:
SELECT *
FROM Customers;
SQL SELECT WHERE Clause
A SELECT statement can have an optional WHERE clause. The WHERE clause
allows us to fetch records from a database table that matches specified
condition(s). For example,
SELECT *
FROM Customers
WHERE last_name = 'Doe';
Another Example:
FROM Customers