当前位置:编程学习 > C#/ASP.NET >>

sql语句问题,在线等。

有一个表table,查询不包含某些行的数据,某些行即是在这个表中筛选的数据:select * from table where .... --------------------编程问答-------------------- 不要select * 
直接select id,name,age (你想要的行) from table where...  --------------------编程问答-------------------- 没有id,而且我只知道我不想要的行。 --------------------编程问答--------------------
引用 2 楼 a6520077 的回复:
没有id,而且我只知道我不想要的行。




你都知道所有行了,把不想要的行去掉就行了 --------------------编程问答--------------------
引用 3 楼 happy09li 的回复:
Quote: 引用 2 楼 a6520077 的回复:

没有id,而且我只知道我不想要的行。




你都知道所有行了,把不想要的行去掉就行了


问题就是怎么去掉啊?

--------------------编程问答-------------------- 你判断的某些行的条件是什么 --------------------编程问答--------------------
引用 5 楼 u011223070 的回复:
你判断的某些行的条件是什么


就是表里的字段 但没有id
--------------------编程问答--------------------
引用 4 楼 a6520077 的回复:
Quote: 引用 3 楼 happy09li 的回复:

Quote: 引用 2 楼 a6520077 的回复:

没有id,而且我只知道我不想要的行。




你都知道所有行了,把不想要的行去掉就行了


问题就是怎么去掉啊?



你的 某些行  是哪些行呢?
要按条件筛选,

--------------------编程问答--------------------
引用 5 楼 u011223070 的回复:
你判断的某些行的条件是什么



比如:select * from table where name = 'a' and age ='b' and address ='c'
      union 
      select * from table where name = 'q' and age ='w' and address ='e'
      union 
      select * from table where name = 'j' and age ='k' and address ='l' --------------------编程问答-------------------- 你用某些行的条件先过滤出来,然后再从所有数据中去除掉。
没有id的话,可以用过滤某些行的条件去对比 --------------------编程问答--------------------
引用 9 楼 lzc2125 的回复:
你用某些行的条件先过滤出来,然后再从所有数据中去除掉。
没有id的话,可以用过滤某些行的条件去对比


如何对比?
--------------------编程问答--------------------

select*   from   TABLE   where   userid   not   in(select   *   from   TABLE)
--------------------编程问答-------------------- 表没有主键吗?
查到所有行的主键,然后主键不在这些记录中的记录就是你要的了 --------------------编程问答-------------------- 表中没有主键。 --------------------编程问答--------------------

SELECT * FROM table WHERE not EXISTS 
(SELECT * FROM  
(select * from table where name = 'a' and age ='b' and address ='c'
      union 
      select * from table where name = 'q' and age ='w' and address ='e'
      union 
      select * from table where name = 'j' and age ='k' and address ='l' ) t
WHERE table.name=t.name and table.age=t.age and table.address=t.address)
--------------------编程问答--------------------
引用 楼主 a6520077 的回复:
有一个表table,查询不包含某些行的数据,某些行即是在这个表中筛选的数据:select * from table where ....
 正解 --------------------编程问答-------------------- 楼主有才,只是说了一句陈述句而已。 --------------------编程问答-------------------- 没有主键么? --------------------编程问答--------------------

select * from 表 where not exists (select 1 from 表 where '唯一主见'='不想显示')
--------------------编程问答-------------------- begin
select *,Identity(int,1,1) as Id into #temp from table
select * from #temp a,(
select * from #temp  where name = 'a' and age ='b' and address ='c'
      union 
      select * from #temp  where name = 'q' and age ='w' and address ='e'
      union 
      select * from #temp  where name = 'j' and age ='k' and address ='l') b
where a.Id<>b.Id
end --------------------编程问答-------------------- --------------------编程问答-------------------- 这个问题居然还有这么多人回答! 怎么答啊    没头没尾的! --------------------编程问答-------------------- 看了下,既然知道所有行,那不想要一些行,用not exists不可以满足要求了么?
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,