"SELECT meta_value FROM wp_postmeta
WHERE post_id ='$id'
AND meta_key = '_product_image_gallery'"
返回94,95,96,97,98,99,100,101,102,103,104,105
所以我认为以下内容将返回id在上面的集合中的所有行,但实际上它只返回行94
"SELECT guid,post_title FROM wp_posts
WHERE ID IN
(SELECT meta_value FROM wp_postmeta
WHERE post_id ='$id'
AND meta_key = '_product_image_gallery'
)"
任何人都明白为什么?
答案 0 :(得分:1)
它只返回第94行,因为字符串的强制" 94,95,96,97,98,99,100,101,102,103,104,105"到整数结果为94。
就好像你的SQL是:
SELECT guid,post_title FROM wp_posts
WHERE ID IN ("94,95,96,97,98,99,100,101,102,103,104,105")
请注意,IN子句中只有一个字符串值,而不是12个整数。