我写的代码部分,
(SELECT meta_value FROM wp_postmeta WHERE meta_key = '_regular_price') price
它给出了子查询返回多行的错误。如何获得价格?
SELECT p1.ID,p1.post_title,p1.post_excerpt,p2.meta_value, p1.guid,
(select p.guid from wp_posts as p where p2.meta_value=p.ID and post_type='attachment') img, (SELECT meta_value FROM wp_postmeta WHERE meta_key = '_regular_price') price
FROM wp_posts p1
JOIN wp_postmeta p2
ON p1.ID = p2.post_id AND
p1.post_type = 'product' AND
p1.post_status = 'publish' AND
p2.meta_key = '_thumbnail_id'
JOIN wp_posts p3
ON p3.ID = p2.post_id
答案 0 :(得分:0)
在您的子查询中添加CONCAT(),以逗号分隔&分组所有结果然后使用FIND_IN_SET作为主查询。