【发布时间】:2017-08-19 21:46:22
【问题描述】:
像这样从 wordpress 中假设表 mysql:
post_id | meta_key | meta_value
19 | poster_url | http://exampleimage.com
19 | vote_average | 7.5
我试过用
SELECT * FROM (Select ID,post_date,post_date_gmt,post_content,post_title,post_status,post_name,post_type,meta_key,meta_value as picture from get_movies where meta_key='poster_url' and post_status='publish' and post_type='post') as a,
(Select meta_value as rate from get_movies where meta_key='vote_average' and post_status='publish' and post_type='post') as b
但结果已重复并错过了 'rate' .. 在这种情况下,我只需要互相制作别名.. 比如 poster_url = 图片,并且 vote_average = rate
有可能吗?
【问题讨论】:
-
你想要什么结果?
-
@GordonLinoff 喜欢 post_id |率 |图片 19 | 7.5 | exmapleimage.com
-
@GordonLinoff 现在我遇到了一个小问题.. 我如何在“WHERE”之后使用这个条件.. 示例:
where post_status = 'publish' and post_type = 'post' and meta_key in ('poster_url', 'vote_average','category') and post_title like '%7%' OR VOTE_AVERAGE LIKE '%7%'