我想尝试运行此查询的情况,我想删除我在表格中保存的最新数据。
DELETE from JOBORDER2 Where ddates in (SELECT TOP 1 * FROM JOBORDER2 Where cjobno = '45' ORDER BY ddates DESC);
但我收到了这个错误。 当未使用EXISTS引入子查询时,只能在选择列表中指定一个表达式。
答案 0 :(得分:4)
尝试
DELETE from JOBORDER2
Where ddates in (
SELECT TOP 1 ddates
FROM JOBORDER2
Where cjobno = '45'
ORDER BY ddates DESC);
这个想法是你试图返回一组(1)“ddates”。
让我们假设最高的“ddates”是'11 / 30/2012'。那么您的查询将等同于:
DELETE from JOBORDER2
Where ddates in ('11/30/2012');
这是有道理的。用“*”,你试图做一些荒谬的事情。括号中有一个行集,即使只有一行,您也要处理多个列。您要与哪个专栏进行比较?
答案 1 :(得分:3)
它不喜欢这位明星。尝试:
DELETE from JOBORDER2 Where ddates in
(SELECT TOP 1 ddates
FROM JOBORDER2
Where cjobno = '45'
ORDER BY ddates DESC);