Insert foreign key failed

1
0
-1

Please can anyone help me please,
I have 3 tables: course(idc, title), participant(idp,username) and registered. the table registered contain (#idc, #idp, date) in MySQL
I want to insert in the table registered a participant in a course.

I do that:

INSERT INTO 'registered' (idc, idp, date) VALUES (
(SELECT idc FROM course WHERE title='${title}';),
(SELECT idp FROM 'participant' WHERE 'username'='${login}';),
CURRENT_DATE);

but it doesn't work!

thanks for help!
Asma

1 answer

1
0
-1

Have tried it with dummy fixed values?

I also note in one select you are using quotes and in the other you're not...any reason why?

What does the log say...?

Regards
Seán

Comments

Submitted by asmahassani on Sat, 01/28/2017 - 00:28

hi sean,
i don't undrestand what you mean.
my objective is to insert in the table registred a new line of a particpant (idp) on a course (idc).
in this requete the value of the idc is the select of th title of the course where the title is entred in the forum.
and the same logic for the idp.
i found the folowing post that help me
http://dba.stackexchange.com/questions/46410/how-do-i-insert-a-row-which...

but any thing happen in the DB.

Notifications