Search code examples
sqldatabasesyntaxdbm

Update query for database


What's wrong with my SQL update? I'm trying to update records with the upcoming value for status records with the value as missed & due_date BETWEEN 2020-08-01 AND 2020-12-31.

Where is the Syntax error?

UPDATE
  records
SET
  status = upcoming,
WHERE
  status = ‘ missed ’ & due_date BETWEEN 2020 -08 -01
  AND  2020 -12 -31 ;

Solution

  • I think this should be written as:

    UPDATE records
       SET status = 'upcoming'
       WHERE status = 'missed' AND
             due_date BETWEEN '2020-08-01' AND  '2020-12-31';
    

    Notes:

    • Strings should be in single quotes.
    • Dates should be in single quotes.
    • SQL uses AND not & for boolean AND.