top of page

SQL (5)

  • Writer: Harmony Pang
    Harmony Pang
  • Sep 24, 2023
  • 1 min read

Updated: Sep 25, 2023





1. DELETE



DELETE p1 FROM Person p1, Person p2
    WHERE p1.email = p2.email AND p1.id > p2.id


DELETE removes the whole row(s) that fulfils the target.




2. DATEDIFF



SELECT w1.id FROM Weather w1, Weather w2
WHERE w1.temperature > w2.temperature AND DATEDIFF(DAY, w1.recordDate, w2.recordDate) = -1


DATEDIFF returns the time unit (e.g. hour, day, year) difference between two dates.


DATEDIFF(DAY, w1.recordDate, w2.recordDate) = -1 means day difference between w1 date and w2 date is 1 day.














Thank you for completing this tutorial!


See you in SQL (6).









© 2023 Harmony Pang. All rights reserved.








Comments


Drop Me a Line, Let Me Know What You Think

Thanks for submitting!

© 2023 by Harmony Pang. All rights reserved.

bottom of page