易截截图软件、单文件、免安装、纯绿色、仅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 字符串处理问题 来者有分


@s='S1,S2,S12,S23';

将@s里面的S1,S2替换成处理,未处理


来者有分.

REPLACE(@s,'S1,S2','处理,未处理')

REPLACE 不好用 自己试下

SQL code:

declare @s ......

sql数据覆盖!

怎么使我每次不是更新数据库
而是覆盖上次的所有记录呢!
因为有时候时间条件不同
SQL code:

select * from hwouttb where
CAST(REPLACE(REPLACE(REPLACE(outdate,'年','-' ),'月','-'),'日','') AS ......

求教一个Sql查询问题。

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

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

简单的sql问题

姓名  学科
a      语文
a      数学
b      英语
b      政治

我想得到  a    语文,数学
  ......

求组sql语句(a+b)=a

求在一同一个表里面
a  b
10  7
(a-b)=a
在原来的表A段更新为3
先谢谢各位了,帮个忙
SQL code:
update a set a=a-b


SQL code:
-->Title:Generating test data
-->Author ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号