Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Database Management - Lecture 2 - SQL select, insert, update and delete

Database Management - Lecture 2 - SQL Select, SELECT DISTINCT, WHERE Clause, Operators, AND, OR and NOT, ORDER BY, Insert, Update, Delete

  • Login to see the comments

Database Management - Lecture 2 - SQL select, insert, update and delete

  1. 1. WEB DEVELOPMENT
  2. 2. PHP PRESENTATORS MD. AL-MAMUN SARKAR
  3. 3. SQL
  4. 4. Structured Query Language
  5. 5. Why SQL Execute queries against a database Retrieve data from a database Insert records in a database Update records in a database Delete records from a database Create new databases Create new tables in a database Create views in a database
  6. 6. Important SQL Commands  SELECT - extracts data from a database  UPDATE - updates data in a database  DELETE - deletes data from a database  INSERT INTO - inserts new data into a database  CREATE DATABASE - creates a new database  ALTER DATABASE - modifies a database  CREATE TABLE - creates a new table  ALTER TABLE - modifies a table  DROP TABLE - deletes a table  CREATE INDEX - creates an index (search key)  DROP INDEX - deletes an index
  7. 7. Select SELECT * FROM table_name; SELECT column1, column2, ... FROM table_name;
  8. 8. SELECT DISTINCT SELECT DISTINCT column_name FROM table_name;
  9. 9. WHERE Clause SELECT column1, column2, ... FROM table_name WHERE condition; Example: SELECT * FROM students WHERE age='15';
  10. 10. Operators  = Equal  <> Not equal. Note: ( != )  > Greater than  < Less than  >= Greater than or equal  <= Less than or equal  BETWEEN Between an inclusive range  LIKE Search for a pattern  IN To specify multiple possible values for a column
  11. 11. AND, OR and NOT AND SELECT * FROM table_name WHERE condition1 AND condition2 AND condition3; OR SELECT * FROM table_name WHERE condition1 OR condition2 OR condition3 ; NOT SELECT * FROM table_name WHERE NOT condition;
  12. 12. ORDER BY SELECT column1, column2, ... FROM table_name ORDER BY column ASC/DESC; Example: SELECT * FROM students ORDER BY id; SELECT * FROM students ORDER BY id ASC; SELECT * FROM students ORDER BY id DESC;
  13. 13. NULL SELECT column_names FROM table_name WHERE column_name IS NULL; SELECT column_names FROM table_name WHERE column_name IS NOT NULL;
  14. 14. INSERT INSERT INTO table_name (column1, column2, column3, ...) VALUES (value1, value2, value3, ...); INSERT INTO table_name VALUES (value1, value2, value3, ...);
  15. 15. UPDATE UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition;
  16. 16. DELETE DELETE FROM table_name WHERE condition; DELETE FROM table_name; DELETE * FROM table_name;
  17. 17. QUESTION ?
  18. 18. THANK YOU

×