0
votes

I have the following structure: Timetable has COMPOSITE PRIMARY KEY that consists of 2 FOREIGN KEYS - [LECTURER'S ID] and [SUBJECT CODE][enter image description here]1

When I'm trying to run the INSERT query INTO Timetable it gives me this error

enter image description here

But at the same time I can enter the values manually in [SUBJECT DETAILS] table without any problems!

enter image description here

How can I INSERT values INTO Timetable using query? Should I create Timetable in different way or something else?

enter image description here

Thank you

2
My guess is you're trying to insert LECTURES_ID or SUBJECT_CODE in TIMETABLE that are not present in LECTURE'S_DETAIS OR SUBJECT_DETAILS respectively. - Harshil Doshi
no, as you can see I have records in [SUBJECT DETAILS] table, the same I have in [LECTURER'S DETAILS] - sinedskid
and I was trying to add the same values which exists in [LECTURER'S DETAILS] and [SUBJECT DETAILS] - sinedskid
May be you're right. Some of the records I can INSERT, some of them not, but both exists in the [LECTURER'S DETAILS] and [SUBJECT DETAILS] tables, I mean values [LECTURER'S ID] and [SUBJECT CODE]. - sinedskid
what is the datatype of DURATION? - Harshil Doshi

2 Answers

1
votes

I've found the problem! Before writing queries I've created tables in Exel

enter image description here

And what I was doing, I was doing copy/paste values from Exel to my queries. But when I tried to write values manually into the queries, it started to work!

I think when I was copying values from Exel, it was copying something else too, SO NEVER EVER COPY VALUES FROM EXEL TO YOUR QUERIES.

0
votes

Try adding the names of the fields.

INSERT INTO TIMETABLE ([LECTURER'S ID], [SUBJECT CODE], [DURATION])
VALUES ('LID001', etc...

If you can, remove apostophes from field names and make all names one word, i.e., LecturersID, SubjectCode, etc.