Hello everybody!
Is it possible to have the WHERE as a wildcard in a SQL query?
I have this simple query:
SQL = "SELECT ID, Firstname, Lastname, Company, City, Email FROM table WHERE * LIKE '%" & q & "%';"
lets say the variable q equals "John Doe". Then I want the query to search for q in both Firstname AND/OR (??) Lastname.
I just can figure it out.
Thanks alot /Andreas
EDIT/UPDATE:
I will try to simplify my question.
Lets say I have a db-table with the ID, Firstname, Lastname and Email fields. (fx with the values: 5, john, Doe, [email protected])
I then have a simple html form with a searchfield (one simple text input with a submit button) on a page where a visitor can search for any of the fields above.
if he/she searches for the word "John", or "Doe", or "hotmail" it works perfect with the SQL query that gets the searchstring as the variable "q" on my ASP page like this:
SQL = "SELECT ID, Firstname, Lastname,Email FROM table WHERE ID LIKE '%" & q & "%', OR Firstnamne LIKE '%" & q & "%', OR Lastname LIKE '%" & q & "%' OR Email LIKE '%" & q & "%';"
Now my question is: How do I do if the visitor types in "John Doe"?
I want to be able to get a list of all the people in my db named "John Doe"