如何在 MySQL 中使用子查询中的字段? [英] How to use field from subquery in MySQL?
本文介绍了如何在 MySQL 中使用子查询中的字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下查询:
SELECT insent.id, notifications.id
FROM insent
WHERE insent.id IN (
SELECT insent_id
FROM notifications
)
;
但这给出了一个错误说:
But this gives an error saying:
字段列表"中的未知列notifications.id"
Unknown column 'notifications.id' in 'field list'
知道我该怎么做吗?
推荐答案
这里的问题是通知表不在范围内试试这个
The problem here is notifications table is not in the scope Try like this
SELECT
i.id,
n.id
FROM insent AS i
JOIN notifications AS n ON n.insent_id = insent.id
这篇关于如何在 MySQL 中使用子查询中的字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文