sql 查询问题
表A
guiGeID shangPinID yanSe chiMa
1 1001 白色 37
2 1001 白色 37
3 1002 黑色 42
4 1002 黑色 42
5 1002 白色 37
6 1003 白色 37
7 1004 白色 37
能否根据表A查询出 shangPinID、yanSe、chiMa 完全相同的所有信息
并且根据 shangPinID 排序
根据上表得到的信息应该如下
guiGeID shangPinID yanSe chiMa
1 1001 白色 37
2 1001 白色 37
3 1002 黑色 42
4 1002 黑色 42
SQL code:
select *
from tb t
where
(select count(1)
from tb
where shangPinID=t.shangPinID and yanSe=t.yanSe and chiMa=t.chiMa
)>1
SQL code:
-- =============================================
-- Author: T.O.P
-- Create date: 2009/11/26
-- Version: SQL SERVER 2005
-- =============================================
declare @TB1 table([guiGeID] int,[shangPinID] int,[yanSe] varchar(4),[chiMa] int)
insert @TB1
select 1,1001,'白色',37 union all
select 2,1001,'白色',37 union all
select 3,1002,'黑色',42 union all
select 4,1002,'黑色',42 union all
select 5,1002,'白色',37 union all
select 6,1003,'白色',37 union all
select 7,1004,'白色',37
select *
from @TB1 a
where 1<(select count(1) from @tb1 where a.
相关问答:
大家帮忙看看这2个sql语句哪个查询的速度更快点。谢谢帮忙。比较着急。在做性能测试。
select * from
表A LEFT OUTER JOIN 表B ON (表A.id || ' ' =表B.id) ,表C , 表D, 表E
Where其他条件
select * ......
我有多个表A B C 结构是一样的,都有2个字段name和content,我要搜索所以表所有字段中包含“中国”的内容 这个SQL语句怎么写
如何将多个表的查询结果连成一个表 这个SQL语句怎么写 表的结构是一样的
例如� ......
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
我要得到一个字符串如:
sdfk|||sgts
sdfsfd|||rgreg
wrfw|||sefw
就是要得到|||后面的字符串,有什么函数吗?怎么用呢?谢谢!
SQL code:
select
right(col,len(col)-charindex('|||',col)-2)
f ......
一个很奇怪的问题
SQL code
select * from Gprs_DataInof
--可以查到所有的数据
select * from Gprs_DataInof where DataTime between 1900-10-16 1:01:00' and '2009-10-20 1:01:00'
--一条数据 ......