Description

The SQL keyword FROM is used to specify a table name, from which records are to be fetched or deleted.

This keyword is used along with the SELECT or DELETE keywords.

  • The keyword SELECT FROM to fetch records from a table.
  • The keyword DELETE FROM to delete records from a table.

SELECT FROM

The below SQL fetches all the columns from a table, for all the records.

SELECT * FROM customers;

The below SQL fetches the specified columns from a table, for all the records.

SELECT customer_id, customer_name, address FROM customers;

The below SQL fetches the specified columns from a table, only for the records qualified by the WHERE condition.

SELECT customer_id, customer_name, address FROM customers
WHERE customer_id IN (1,2,3,4,5);

DELETE FROM

The below SQL deletes a single record from a table, that matches the customer ID specified in the WHERE condition.

DELETE FROM customers
WHERE customer_id = 5;

The below SQL deletes multiple records from a table, that matches the customer ID specified in the WHERE condition.

DELETE FROM customers
WHERE customer_id IN (1,2,3,4,5);

The below SQL deletes all records from a table, as the WHERE condition is not provided.

DELETE FROM customers;

Related Links