I'm trying to create a lookup script for my application. The current table structure looks like this:
id userid profile_field profile_value
-----------------------------------------------------
1 1 firstname John
2 1 lastname Smith
3 1 address 123 anywhere
4 1 city city
5 2 firstname Jane
6 2 lastname Smith
7 2 address 456 anywhere
8 2 city town
I'm trying to write a query that will allow me to search for users based on user input.
For example, my admins would want to search for users with last name like "smith". In this example, it would return user ids 1 and 2.
Is this possible to do with mysql? So far, I've looked into mysql's group_concat function, but it seems like it puts everything into a string instead of columns. Thus, I can't generate a proper where clause for searching.
EDIT: I must apologize, I should have been more clear.
I also need to consider having more than one input. For example, search for users with first name like "john" AND last name like "smith". In this example, it would only return user id 1.
That's the part that I'm having trouble with. Sorry again!