SQL

[Basic Grammar] SQL SELECT Statement

grace21110 2023. 10. 12. 20:44
반응형

SELECT statement is used to select data from a database. 

 

Example

SELECT CustomerName, City FROM Customers;
  • Syntax 
SELECT column1, column2, ...
FROM table_name;
  • Select all columns

Example

SELECT * FROM Customers;

 

Let's solve the following exercises together. 

 

Exercises

 

  1. Write an SQL query to retrieve all the records from a table named "Employees."
  2. SELECT * FROM Employees;
  3. Create an SQL query to fetch the titles and publication dates of all books from a table named "Books."
  4. SELECT title, publication_date FROM Books;
  5. Write an SQL query to retrieve the product IDs and names of all products from a table named "Products."
  6. SELECT product_id, product_name FROM Products;