Vote count:
0
I want to insert and update a table using one mysql query my table structure is :
student_id ,class_no, section, started_on ,ended_on
I want to update class_no and insert a new records. For that I am using this query :-
INSERT INTO student_classes (student_id,class_no,section,started_on,ended_on)
VALUES (835,5,0,2013-04-09,null) ON DUPLICATE KEY UPDATE class_no = class_no+1
but this query is only insert a new row,not updated column if I use where clause after DUPLICATE KEY UPDATE class_no = class_no+1 its give error message. Message is :- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where started_on=2013-04-09'
asked 47 secs ago
update and insert using single my sql query
Aucun commentaire:
Enregistrer un commentaire