1

I'm running this SQL query:

$regSql = "INSERT INTO orderregel(AANTAL) VALUES('$aant') WHERE TAAK_ID='$TkID'";

I also tried this one:

$regSql = "INSERT INTO orderregel(AANTAL) VALUES('$aant') WHERE TAAK_ID=$TkID";

But it both gave this error:

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 TAAK_ID='13'' at line 1

What might be the solution?

Dharman
  • 30,962
  • 25
  • 85
  • 135

1 Answers1

5

insert into syntax doesn't have where

INSERT INTO table_name
VALUES (value1,value2,value3,...);

probably you wanted to use insert into select

INSERT INTO table
( column name(s))
SELECT column name(s) from table where condition

OR

IF ( condition )
INSERT INTO table_name
VALUES (value1,value2,value3,...);
radar
  • 13,270
  • 2
  • 25
  • 33