Har*_*rry 6 mysql sql subquery
SELECT * FROM `image_appreciations`
WHERE `image_id` IN(SELECT `id` FROM `images` WHERE `user_id` = '1')
Run Code Online (Sandbox Code Playgroud)
是我当前的查询,它返回零结果
SELECT `id` FROM `images` WHERE `user_id` = '1'
Run Code Online (Sandbox Code Playgroud)
作为子查询返回大约8个id,其中有两个被发现
SELECT * FROM `image_appreciations`
WHERE `image_id` IN(77,89)
Run Code Online (Sandbox Code Playgroud)
这很好.但总之,它失败了.我究竟做错了什么?
这可以使用JOIN.下面是使用隐式短手语法的示例.
SELECT * FROM image_appreciations a, images i
WHERE a.image_id = i.id AND i.user_id = 1
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8491 次 |
| 最近记录: |