Exercise on SQL LIKE query

SQL LIKE

  1. Display all records who’s name starts with John
  2. Display all records who’s name ends with John
  3. Display all records who’s name have John ( can be any where )
  4. Display all records who’s name starts with A and ends with n
  5. Display all records who’s name have no ( case sensitive )
  6. Display all records who got mark in nineties but not equal to 100
  7. Display all records who have alex or deo any where in name column
  8. Display all records who have alex and Jon any where in name column
  9. Display all records who have alex or Jon any where in name column
  10. Display all records who have ro any where in name column and got mark in nineties



  • Video Tutorial on LIKE Query with AND , OR NOT combinations.


Solution ( Query ) USE my_db;
  1. SELECT * FROM student WHERE name LIKE 'John%'; # 1 , starting with John
  2. SELECT * FROM student WHERE name LIKE '%John'; # 2 , ending with John
  3. SELECT * FROM student WHERE name LIKE '%John%'; # 3 , Any where John is there
  4. SELECT * FROM student WHERE name LIKE 'A%n'; # 4 , Starts with A and ends with n
  5. SELECT * FROM student WHERE name LIKE binary '%no%'; # 5 , Case sensitive search
  6. SELECT * FROM student WHERE mark LIKE '9_'; # 6 , Mark in nineties
  7. SELECT * FROM student WHERE name LIKE '%alex%' OR name like '%deo%'; # 7 , alex or deo
  8. SELECT * FROM student WHERE name LIKE '%alex%' AND name like '%John%'; # 8 , alex and John
  9. SELECT * FROM student WHERE name LIKE '%alex%' OR name like '%John%'; # 9 , alex OR John
  10. SELECT * FROM student WHERE name LIKE '%ro%' AND mark LIKE '9_'; # 10 , ro AND Mark in nineties


plus2net.com






Post your comments , suggestion , error , requirements etc here
















We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2020 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer