I'm trying to execute this query:
String req="INSERT INTO`fos_user`(`addressmailperso`,`pays`,`job`,`sexe`, `addressjob`,`skills`,`description`) VALUES (?,?,?,?,?,?,?) WHERE username='"+Apptest.current+"';";
this error occured: Syntax error near 'WHERE username ='fayrouz''in line 1.
Ousmane D.
56.6k8 gold badges101 silver badges134 bronze badges
asked Mar 25, 2017 at 17:33
Fayrouz Ouerghi
1701 gold badge2 silver badges12 bronze badges
1 Answer 1
In insert there is not where so you should use
String req="INSERT
INTO fos_user (addressmailperso,pays,job,sexe, addressjob,skills,description)
VALUES (?,?,?,?,?,?,?)";
could be you need an update
String req="UPDATE `fos_user`
set `addressmailperso` = ?
,`pays` = ?
,`job` =?
,`sexe` = ?
, `addressjob` =?
,`skills` = ?
,`description` =?
WHERE username='"+Apptest.current+"';";
answered Mar 25, 2017 at 18:05
ScaisEdge
134k10 gold badges98 silver badges111 bronze badges
Sign up to request clarification or add additional context in comments.
2 Comments
Fayrouz Ouerghi
I changed the query to : " UPDATE fos_user SET addressmailperso = ? , pays = ? ,job = ?, sexe = ?, addressjob = ?, skills = ? , description = ? WHERE username = " +Apptest.current; But I still have an error: Field 'fayrouz' unknown in where clause. Btw, Apptest.current is a variable that contains the username of the current user of the application wich is Fayrouz.
ScaisEdge
@FayrouzOuerghi you must wrap the Apptest.current with single quotes like in my sample code. in your code (the code you provided in comment) you missed the single quote. If you don't use quote around the var the name is assumed as column name and not as a literal value .. so look how the single quotes are placed in req string
default
WHEREin a standardINSERTstatement. You probably need anUPDATEstatement instead.