[wp-hackers] User Meta Query Assistance

Williams Phillip phil.m.williams at gmail.com
Sun Jan 13 17:15:03 GMT 2008


You need to use a subselect as a scalar operand in your query. So  
something like the following should work:

SELECT
	(SELECT meta_value from wp_usermeta where meta_key = 'first_name'  
AND user_id = 2) as first,
	(SELECT meta_value from wp_usermeta where meta_key = 'last_name' AND  
user_id = 2) as last,
	wp_users.*
FROM
	wp_users
WHERE
	wp_users.ID = 2


Phil
phil.m.williams at gmail.com




On Jan 13, 2008, at 10:26 AM, Mike Walsh wrote:

> I think my lack of SQL expertise is preventing me from figuring  
> this out on
> my own .  ;-)
>
>
>
> I would like to construct a query which returns first name and last  
> name
> information from wp_usermeta table and all of the info from the  
> wp_user
> table as a single record.  Because the meta fields aren't stored as  
> columns
> in the table, I am unsure how to do this.  Is it possible?
>
>
>
> Thanks,
>
>
>
> Mike
>
>
>
> --
>
> Mike Walsh - mike_walsh at mindspring dot com
>
>
>
>
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list