How to write statement using LIKE statement in jsp
hi
I am new to jsp. I would like to retrive the data from database using like command. But my query dosen't work well. Can you help me in this topic.
String name = request.getParameter("username");
int i = st.executeQuery("select * from emp where empname LIKE '%name%'");
Plase help me..
Thanking you
sure...
[354 byte] By [
sure_2912a] at [2007-11-26 14:33:43]

# 1
Using LIKE :
==========
The following SQL statement will return persons with first names that start with an 'O':
SELECT * FROM Persons
WHERE FirstName LIKE 'O%'
The following SQL statement will return persons with first names that contain the pattern 'la':
SELECT * FROM Persons
WHERE FirstName LIKE '%la%'
Hope this might have helped you
REGARDS,
RaHuL
# 2
String name = "%" + request.getParameter("username") + "%";
String sql = "select * from emp where empname LIKE '" + name + "'";
int i = st.executeQuery(sql);