SELECT NAME FROM ABCD WHERE NAME LIKE "+aero+%"AND ROWNUM <= 10
what is the syntax error in this line......SELECT NAME FROM ABCD this is working
SELECT NAME FROM ABCD WHERE NAME LIKE "+aero+%"AND ROWNUM <= 10
what is the syntax error in this line......SELECT NAME FROM ABCD this is working
Double quotes around the literal?
No space between the literal and AND?
EDIT:
con.prepareStatement(
"SELECT name FROM abcd WHERE name LIKE '" + aero + "%' AND ROWNUM <= 10");
Will find all strings starting with your variable aero
.
To get all strings containing the String of your variable aero
use
con.prepareStatement(
"SELECT name FROM abcd WHERE name LIKE '%" + aero + "%' AND ROWNUM <= 10");
You need to use single-quotes instead of double-quotes:
SELECT name
FROM abcd
WHERE name LIKE '+aero+%'
AND ROWNUM <= 10;
If the double-quotes are in the string you search use '"+aero+%"'
.
If you only want to search for strings containing aero
, use '%aero%'
.
You need single quotes:
SELECT NAME FROM ABCD WHERE NAME LIKE '+aero+%' AND ROWNUM <= 10
And also a space before AND.
UPDATE
It's not clear in your question what exactly you're searching for. You may need one of the following instead:
SELECT NAME FROM ABCD WHERE NAME LIKE '"+aero+%"' AND ROWNUM <= 10
SELECT NAME FROM ABCD WHERE NAME LIKE '%"+aero+"%' AND ROWNUM <= 10
SELECT NAME FROM ABCD WHERE NAME LIKE '"%+aero+%"' AND ROWNUM <= 10
... or some other variation. But the important thing is that you should surrond literals with single quotes and not double quotes.
You need to give the character between the expression and AND operator . And give single quotes for your regular expression
If you called that from some program codes, following is more likely, where aero
is the variable, and % would be acts as wildcard. When aero is ab
, it will search for 'ab','abc', 'abcd', .......
"SELECT NAME FROM ABCD WHERE NAME LIKE '"+aero+"%' AND ROWNUM <= 10;"
It isn't clear to me whether your aero is a literal string 'aero' or the name of a variable in your program. If it is a literal then do this:
pr = con.prepareStatement
("SELECT NAME FROM ABCD WHERE NAME LIKE 'aero%' AND ROWNUM <= 10");
If it is a variable then you should use a bind variable. Not only is the syntax much less confusing, it also prevents SQL injection attacks. I'm no ASP expert, but the syntax is something like:
pr = con.prepareStatement
("SELECT NAME FROM ABCD WHERE NAME LIKE ?||'%' AND ROWNUM <= 10");
con.setString(1,aero);