select rf_id, bname
from books
where rf_id not in (select *
from books
where rf_id='" + tocheck + "');
执行时,它引发了以下错误。请帮我解决这个错误。
当未使用EXISTS
引入子查询时,只能在选择列表中指定一个表达式
答案 0 :(得分:1)
IN
运算符希望将rf_id
与单个列进行比较,因此应该是:
where rf_id not in (select rf_id....
但是,鉴于子查询受到rf_id
的限制,您最好将查询更改为:
select rf_id, bname
from books
where rf_id <> '" + tocheck + "'
答案 1 :(得分:0)
使用:
select rf_id, bname
from books
where rf_id not in (select rf_id
from books
where rf_id='" + tocheck + "')