Have a problem that seems easy on paper but i'm having a big problem figuring out how best to write a single query.
I have a table
CREATE TABLE `profile_values` ( `fid` int(10) unsigned NOT NULL default '0', `uid` int(10) unsigned NOT NULL default '0', `value` text, PRIMARY KEY (`uid`,`fid`), KEY `fid` (`fid`) )
The point of this table is to store profile information on a user.
E.g. a typically row would look like this..
fid | uid | value __________________ 1 | 77 | Mary 11 | 77 | Poppins 1 | 123 | Steve 11 | 123 | Davis
Note:
'fid' of '1' represents the first name 'fid' of '11' represents the last name 'uid' is a users id within the site.
What I am trying to achieve is to bring back all uid's that satisfy the condition of first name like 'S%' and last name like 'D%'.
The reason i need this is because i have an autocomplete search box for users on the site.
So if i type 'S' in the search box i will see list of all users that begin with the letter 'S', if i now type a whitespace and 'D' i should now be able to see the list of users who match both conditions.
Does anyone have any idea how this can be accomplished? Thanks in advance.