select meta_value from YOURTABLENAME where user_id=197
and meta_key in ('first_name','last_name')
Or if You want to select them separately:
select meta_value from YOURTABLENAME where user_id=197 and meta_key='last_name';
select meta_value from YOURTABLENAME where user_id=197 and meta_key='first_name';
You could use the second condition in the WHERE clause to achieve what you want. It’s important to wrap the second condition inside parentheses. Like this:
SELECT *
FROM wp_usermeta
WHERE user_id = 1
AND
(
CONVERT(meta_key USING utf8) = 'first_name'
OR
CONVERT(meta_key USING utf8) = 'last_name'
)
Which outputs this:
If you only need the meta_value column, then you could use this:
SELECT meta_value
FROM wp_usermeta
WHERE user_id = 1
AND
(
CONVERT(meta_key USING utf8) = 'first_name'
OR
CONVERT(meta_key USING utf8) = 'last_name'
)
3
Answers
If You want to select them in one query:
Or if You want to select them separately:
Try this:
You could use the second condition in the
WHERE clause
to achieve what you want. It’s important to wrap the second condition inside parentheses. Like this:Which outputs this:
If you only need the
meta_value
column, then you could use this:Which outputs this: