insert into sws(grade) values(100) where student_id='$session_id' & cys='$get_id2'
It shows error as
You have an error in your sql syntax; check manual that corresponds to your MYSQL server version for right syntax to use near 'WHERE student_id='21' & cys='java' at line 1
Use Update Command not Insert
Replace the & with AND (read about MySQL AND syntax).
INSERT syntax cannot have WHERE clause as you used, you might want to use UPDATE.
Basic UPDATE syntax :
UPDATE table_name
SET column1 = value1, column2 = value2...., columnN = valueN
WHERE [condition];
Related
I'm creating a stored procedure using phpmyadmin for mysql 5.5.55 .
INSERT INTO drama_ (value1,value2,value3,value4,value5,value6)
VALUES (val1,val2,0,0,0,0);
SELECT LAST_INSERT_ID();
but i'm getting a syntax error in SELECT LAST_INSERT_ID();
EDIT :
You have an error your SQL syntax: check the manual that corresponds to your MYSQL server version for the right syntax to use near 'SELECT LAST_INSERT_ID()' at line 4
Im trying to update a longtext type field called 'comment' using a simple sql query in mysql client like this :
Update mytable set comment='Test' where id = 1;
But i'm getting this error
ERROR 1064 (42000): 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 'comment='Test' where id = 1' at line 1
Am i missing something ?, thanks in advance.
comment is a reserved word, if you want to have a table/field with that name, you have to quote it (or use the table.fieldname syntax, in case of a field). default in mysql is the backtick for that, so:
update mytable set `comment`='Test' where id = 1;
Found it, it gets solved with this:
update mytable as a set a.comment='Test' where id = 1;
what's wrong with this query?
UPDATE `order` SET `total_no_vat` = IF(`total` IS NULL,NULL,(`total`/(1.10)));
I get an error that I cannot interpret:
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 ') )' at line 1
any clue?
You can simply do:
UPDATE `order` SET `total_no_vat` = `total`/(1.10);
If total is NULL then total/(1.10) evaluates to NULL.
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?
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,...);
I'm trying to track the page views by inserting only unique values every 24h.But when I run this query I get a syntax error.
insert ignore into profilepageviews values( '77.777.777.777' , CURRENT_TIMESTAMP, '5') where hitdate NOT LIKE '%2012-06-26%'
Error:
#1064 - 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 hitdate NOT LIKE '%2012-06-26%'' at line 1
You can not use WHERE clause with INSERT, You might want UPDATE