totally new to MySQL and am trying to extract some data - I was expecting this to be a relatively simple task but I didnt realise that the "format" of the data extract wouldnt have the column headings i expected. I've done some research and think I'm very close to the answer, provided here:
However, when writing my query I'm getting a syntax error.
So here is the code I've applied (using a little common sense to work out my specific values, although may have totally missed the mark!)
SELECT wp_usermeta.User_ID
MAX(CASE WHEN wp_usermeta.meta_key = 'nickname' THEN wp_usermeta.meta_value ELSE NULL END) AS 'nickname',
MAX(CASE WHEN wp_usermeta.meta_key = 'sex' THEN wp_usermeta.meta_value ELSE NULL END) AS 'sex'
FROM wp_usermeta
GROUP BY wp_usermeta.User_ID
The error I'm getting is a #1064 advising to check the syntax on line 2 near 'MAX(CASE WHEN wp_usermeta.meta_key = 'nickname' THEN wp_usermeta.meta_value ELSE'
I'm sure this is a simple syntax error but i can't work it out!
Many thanks,
Stuart