select *
from [table] t
where
not exists(
select 1
from [table]
where 名称=t.名称
and (价格>t.价格 or 价格=t.价格 and 主键<t.主键)
)
原帖:
http://topic.csdn.net/u/20100727/10/c041e543-049d-4305-a4aa-a3dcbccb71c7.html?seed=134882218&r=67265807#r_67265807教教思路啊 带exists的语句好迷糊什么时候用exists啥时候用not exists
子句里 字段<,>,or,and 怎么用?我只知道 按什么分组 就一定有个表达式是 分组字段=别名.分组字段
别的表达式呢 什么思路啊?
from [table] t
where
not exists(
select 1
from [table]
where 名称=t.名称
and (价格>t.价格 or 价格=t.价格 and 主键<t.主键)
)
原帖:
http://topic.csdn.net/u/20100727/10/c041e543-049d-4305-a4aa-a3dcbccb71c7.html?seed=134882218&r=67265807#r_67265807教教思路啊 带exists的语句好迷糊什么时候用exists啥时候用not exists
子句里 字段<,>,or,and 怎么用?我只知道 按什么分组 就一定有个表达式是 分组字段=别名.分组字段
别的表达式呢 什么思路啊?
from [table] t
where
not exists(
select 1
from [table]
where 名称=t.名称
and (价格>t.价格 or (价格=t.价格 and 主键<t.主键))
)
子句里 字段<,>,or,and 怎么用先理解意思?
http://topic.csdn.net/u/20090626/12/C5A614FA-AF52-4EA1-82C7-0C0A6EB3AE85.html看看8楼
嗯 那儿小FJJ的7楼好高
1.取主查询一条记录。
2.根据这条记录判断子查询记录数是否大于零
3.如果大于零则将主查询中该记录加入结果集。否则不加入。
4.取下一条记录,如果有,则再次从第2步循环到此。如果没有(到记录尾),则输入出查询结果。