易截截图软件、单文件、免安装、纯绿色、仅160KB

sql语句问题

有一个表AA
name  tj
1    a
1    b
1    c
2    a
2    d
3    b
要求当tj字段的值既等于a又等于c时(tj = ‘a’又要tj = ‘b’)
也就是说我的查询条件是a、c,我要查的结果是1
SQL code:
select name from
(
select distinct name from aa where tj ='a'
union all
select distinct name from aa where tj ='b'
) t
group by name having count(1) = 2


SQL code:

select * from AA where tj='a' and tj='c'



引用
SQL codeselect*from AAwhere tj='a'and tj='c'

理解錯誤.大烏龜正解.

引用
SQL codeselect namefrom
(selectdistinct namefrom aawhere tj='a'unionallselectdistinct namefrom aawhere tj='b'
) tgroupby namehavingcount(1)=2


up

SQL code:
create table aa(name int, tj varchar(10))
insert into aa values(1 , 'a')
insert into aa values(1 , 'b')
insert into aa values(1 , 'c')
ins


相关问答:

SQL语句提问

现有表  Term
结构如下

time1 time2 idterm
2009-2-15 2009-6-30 11
2009-9-10 2010-1-15 12

如果输入 2009-4-25 则应该取出idterm 11
如果输入 2009-12-5 则应该取出idterm 12 ......

求教一个Sql查询问题。

有三个表一个是采购单格式如下
入库单表:

入库单号      产品        质检编号      入库数量
001          品种1&n ......

一个SQL语句的问题。高手帮帮忙

有两个表。分别都有ID主键。A表的ID和B表的ID是对应的,就是A表几个ID,B表就几个ID。A表的ID是什么,B表的ID就是什么。
可是现在A表的ID比B表的多了。
我现在想要把B表中少的部分给补齐了。这个插入应该怎么写 ......

linq to sql的问题

linq to sql里怎样使它在插入数据时自动截断过长的字符串而不是抛出错误
。。。。。。。。。。我通常都是提交时就检查他在长度。。。

不是,现在是项目做完了,很多模块插入数据时都出现这样的问题。以前用sqlpa ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号