Reputation: 1
Help me with sql
i have an table here: click here to see table
i want to add a new row like this "first name"
meta_key = first_name and the coresponding meta_value where basical looks like this
first name ---------- arnold gear john dude
Upvotes: 0
Views: 318
Reputation: 92815
Try
SELECT MIN(CASE WHEN meta_key = 'first_name' THEN meta_value END) first_name,
MIN(CASE WHEN meta_key = 'last_name' THEN meta_value END) last_name
FROM wp_usermeta
WHERE meta_key IN ('first_name','last_name')
GROUP BY user_id
Sample output:
| FIRST_NAME | LAST_NAME | --------------------------- | Patrice | Fitzgerald | | Jhon | Doe | | Mark | (null) |
Here is SQLFiddle demo
Upvotes: 2