Advertisement
YavorGrancharov

Built-in Functions - Lab

Oct 5th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.55 KB | None | 0 0
  1. SELECT title FROM books
  2. WHERE SUBSTRING(title,1,3) = 'THE' ORDER  BY id;
  3.  
  4. //SELECT title FROM books WHERE title LIKE 'The%' ORDER BY id;
  5. --------1
  6. UPDATE books SET title = REPLACE(title,'The','***')
  7. WHERE SUBSTRING(title,1,3) = 'The';
  8. SELECT title FROM books WHERE SUBSTRING(title,1,3) = '***' ORDER BY id;
  9. -------2
  10. SELECT SUM(cost) FROM books;
  11. --------3
  12. SELECT concat(`first_name`,' ',`last_name`) AS 'full_name',
  13. TIMESTAMPDIFF(DAY,`born`,`died`) AS 'days_lived' FROM authors;
  14. ----------4
  15. SELECT title FROM books WHERE title LIKE 'Harry%' ORDER BY id;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement