[wp-hackers] User Meta Query Assistance

Andre SC andre at pixelplexus.co.za
Sun Jan 13 18:49:35 GMT 2008


For interest sake, I hear '...WordPress still supports MySQL 4.0, which 
does not allow subqueries *at all* (4.1 and up;'
 so you might need to run the selects separately if its for the wild.

Williams Phillip wrote:
> 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
>
> _______________________________________________
> 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