fundamentals/database/notes/05-sql-primer-worksheet.md
2022-07-21 00:20:43 +05:30

2.8 KiB

Queries

Insert queries

  1. Insert a row with your name and all the other fields in students table
    
  1. Insert a row with just mandatory fields in students table
    

Select Queries

  1. Get all students

    
    
  2. Get first and last name of all students

    
    
  3. Get first name of all students with output column name as Student Name

    
    
  4. Get all unique addresses of all students

    
    
  5. Get all students with ID equal to 1

    
    
  6. Get all students with IQ greater than 150

    
    
  7. Get all students with IQ less than 100

    
    
  8. Get all students with IQ greater than 100 and less than150

    
    
  9. Get all students with IQ greater than 100 or less than 150

    
    
  10. Get all students with first name Tantia

    
    
  11. Get all students with first name Tantia and last name Tope

    
    
  12. Get all students with first name John or first name Mycroft

    
    
  13. Get all students with name John Watson or Mycroft Holmes

    
    
  14. Get all students without the first name John

    
    
  15. Get all students without the first name John or first name Mycroft

    
    
  16. Get all students with first name starting with T

    
    
  17. Get all students with last name ending with walker

    
    
  18. Get all students with first name containing T

    
    
  19. Get all students with last name in the format ___walker

    
    
  20. Get all students from Jhansi and London

    
    
  21. Get all students which do not have a batch id

    
    
  22. Get the first 5 students

    
    
  23. Get the first 5 students sorted by IQ

    
    
  24. Get the first 5 students sorted by IQ in descending order

    
    
  25. Get the first 5 students sorted by IQ in descending order and then by first name

    
    

Update Queries

  1. Update a row

    
    
  2. Update a row with a condition

    
    
  3. Update multiple columns

    
    

Delete Queries

  1. Delete a row with a condition

    
    
  2. Delete multiple rows

    
    

Joining Queries

  1. Get first name and last name of all students and their batch names

    
    
  2. Get first name and last name of all students and their instructor names