I am trying to use some values taken from the user in an SQL query and trying to search on basis of that input. I did a little research and found this on web.
st.executeQuery("SELECT * FROM Users WHERE UserName LIKE 'userName%'");
I then tried changing it to
st.executeQuery("SELECT * FROM Users WHERE UserName='userName%'");
But that didn't work. Also I've tried using '@userName'
but that doesn't work either. So Now I am here since clearly I am making some obvious mistake or none of the above methods are correct. Now if I hardcode the values
st.executeQuery("SELECT * FROM Users WHERE UserName='Anwer'");
it works fine. So I think I am making mistake on how to use the program's values. I am using SQL Management Studio 2012 Programming Language Java.