What’s wrong with my query?

It’s saying I have an error in my SQL syntax but according to my class notes, I think this is how I’m meant to do it, am I wrong? I’m trying to make a message about a consistency constraint, using the table MESSAGE, and the idea is that it shows ” The different driving schedules assigned to a driver must not overlap with each other.”

>INSERT INTO MESSAGE

( SELECT DISTINCT CONCAT(‘A driver’, S.LNUM, ‘schedule’, S.SNUM, ‘between’, S.START_DATE_TIME, ‘and’ , S.RETURN_DATE_TIME,’ overlapped with schedule’ , SS.SNUM, ‘between’ , SS.START_DATE_TIME,’and’ SS.RETURN_DATE_TIME.)

FROM SCHEDULE AS S JOIN SCHEDULE AS SS ON S.LNUM = SS.LNUM

WHERE SS.START_DATE_TIME > S.START.DATE.TIME

AND SS.START_DATE_TIME < S.RETURN_DATE_TIME);

submitted by /u/Tgypmo
[link] [comments]


Go to Source of this post
Author Of this post: /u/Tgypmo
Title Of post: What’s wrong with my query?
Author Link: {authorlink}