liltyga
asked on
Reference variables in SQL SELECT Statement
The JSP newbie here again....
I'm passing form values to a page, and want to reference one of the variables in my SELECT statement - that is - instaed of using
ResultSet rs = stmt.executeQuery("SELECT * FROM TABLE_T WHERE ACCT_NO = 123 ");
I want to use a variable for the account number instead of the actual number. I can reference that number by using <%= request.getParameter("cust n") %>, but that synatax won't work if I use it in the SELECT statement like so:
ResultSet rs = stmt.executeQuery("SELECT * FROM TABLE_T WHERE ACCT_NO = request.getParameter("cust n") ");
I know I'm doing something wrong, but what?
Thx again for the help - I don't know what I would do without this site!
lil
I'm passing form values to a page, and want to reference one of the variables in my SELECT statement - that is - instaed of using
ResultSet rs = stmt.executeQuery("SELECT * FROM TABLE_T WHERE ACCT_NO = 123 ");
I want to use a variable for the account number instead of the actual number. I can reference that number by using <%= request.getParameter("cust
ResultSet rs = stmt.executeQuery("SELECT * FROM TABLE_T WHERE ACCT_NO = request.getParameter("cust
I know I'm doing something wrong, but what?
Thx again for the help - I don't know what I would do without this site!
lil
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks so much you guys! :)
SELECT * FROM TABLE_T WHERE CURDATE LIKE '2003-01-01%'
SELECT * FROM TABLE_T WHERE CURDATE LIKE '01-01-2003%'
SELECT * FROM TABLE_T WHERE CURDATE > '2003-01-01:00.00.00' AND CURDATE<= '2003-01-01:23:59:59'
SELECT * FROM TABLE_T WHERE CURDATE LIKE '01-01-2003%'
SELECT * FROM TABLE_T WHERE CURDATE > '2003-01-01:00.00.00' AND CURDATE<= '2003-01-01:23:59:59'
ResultSet rs = stmt.executeQuery("SELECT * FROM TABLE_T WHERE ACCT_NO LIKE '"+ custn +"'");
It will work