|
 |
asp_databases thread: Syntax error
Message #1 by "urmilla" <urmi_tikoo@m...> on Thu, 26 Jul 2001 10:54:13
|
|
hello,
i am using the following sql statement where username is coming from
session but i am getting the error
"""""Incorrect syntax near the keyword 'where'. """""
SQL=insert into members ( recruit ) values ( 'yes' ) where username
like '%"&username&"%'"
can anyone please help me
Regards
Message #2 by Gee Vee <happygv@y...> on Thu, 26 Jul 2001 03:07:45 -0700 (PDT)
|
|
Hi Urmila,
INSERT INTO statement desnt support WHERE Clause.
Could not identify what u are trying to do. pls mail
in detail.
Cheers!!
Vijay.G
Message #3 by "Taher Moiyed" <taherm@f...> on Thu, 26 Jul 2001 11:12:15 +0100
|
|
Try this one
SQL=insert into members ( recruit ) values ( 'yes' ) where username
like "'%"& username & "%'"
taher
-----Original Message-----
From: urmilla [mailto:urmi_tikoo@m...]
Sent: 26 July 2001 10:54
To: ASP Databases
Subject: [asp_databases] Syntax error
hello,
i am using the following sql statement where username is coming from
session but i am getting the error
"""""Incorrect syntax near the keyword 'where'. """""
SQL=insert into members ( recruit ) values ( 'yes' ) where username
like '%"&username&"%'"
can anyone please help me
Regards
-
Message #4 by "Eoghan O'Byrne" <Eoghan.O'Byrne@W...> on Thu, 26 Jul 2001 11:24:39 +0100
|
|
Hey Urmilla,
First off, you don't have an opening " and secondly you can't use a
where clause like that in an insert statement.
Using WHERE means that the row must already exist so you should use an
UPDATE statement as follows,
SQL =3D "UPDATE members SET recruit =3D 'yes' WHERE username like
'%"&username&"%'"
You should also be careful with your column name as words like username
etc. are reserved words for many database engines.
If you really need to insert a new column with the value of 'yes' You
need to select that value from an existing row as follows,
SQL =3D "INSERT INTO members(recruit) SELECT columnWithYesValue FROM
table
WHERE username =3D '%" &username& "%'"
Regards,
Eoghan
-----Original Message-----
From: urmilla [mailto:urmi_tikoo@m...]
Sent: Thursday, July 26, 2001 11:54 AM
To: ASP Databases
Subject: [asp_databases] Syntax error
hello,
i am using the following sql statement where username is coming from
session but i am getting the error
"""""Incorrect syntax near the keyword 'where'. """""
SQL=3Dinsert into members ( recruit ) values ( 'yes' ) where username
like '%"&username&"%'"
can anyone please help me
Regards
Message #5 by "Eoghan O'Byrne" <Eoghan.O'Byrne@W...> on Thu, 26 Jul 2001 11:33:29 +0100
|
|
Actually, the insert statement at the bottom of my last message wont
work.
You can only use where clauses to input by using UPDATE
Regards,
Eoghan
-----Original Message-----
From: Eoghan O'Byrne [mailto:Eoghan.O'Byrne@W...]
Sent: Thursday, July 26, 2001 11:25 AM
To: ASP Databases
Subject: [asp_databases] RE: Syntax error
Hey Urmilla,
First off, you don't have an opening " and secondly you can't use a
where clause like that in an insert statement.
Using WHERE means that the row must already exist so you should use an
UPDATE statement as follows,
SQL =3D "UPDATE members SET recruit =3D 'yes' WHERE username like
'%"&username&"%'"
You should also be careful with your column name as words like username
etc. are reserved words for many database engines.
If you really need to insert a new column with the value of 'yes' You
need to select that value from an existing row as follows,
SQL =3D "INSERT INTO members(recruit) SELECT columnWithYesValue FROM
table
WHERE username =3D '%" &username& "%'"
Regards,
Eoghan
-----Original Message-----
From: urmilla [mailto:urmi_tikoo@m...]
Sent: Thursday, July 26, 2001 11:54 AM
To: ASP Databases
Subject: [asp_databases] Syntax error
hello,
i am using the following sql statement where username is coming from
session but i am getting the error
"""""Incorrect syntax near the keyword 'where'. """""
SQL=3Dinsert into members ( recruit ) values ( 'yes' ) where username
like '%"&username&"%'"
can anyone please help me
Regards
Message #6 by "urmilla" <urmi_tikoo@m...> on Thu, 26 Jul 2001 11:46:34
|
|
hi,
Eoghan,
It really worked.Thanks a lot.
Regards
urmi
|
|
 |