易截截图软件、单文件、免安装、纯绿色、仅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语句正确但是RESULTSET中没有值

StringBuffer str = new StringBuffer("select * from menu where parentid=1 and mid <>1 order by parentid");

List list = new ArrayList();
ResultSet rst = null;
DataBa ......

linq to sql的问题

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

不是,现在是项目做完了,很多模块插入数据时都出现这样的问题。以前用sqlpa ......

求组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 ......

求这句Sql如何理解

create table [客户联系表]([客户编号] varchar(2),[联系日期] datetime,[联系内容] int)
insert [客户联系表]
select 'aa','2009/01/01',111 union all
select 'bb','2009/02 ......

SQL语句问题

create trigger TR_Delete_pm_WorkCard
on pm_WorkCard
for delete
as
if @@rowcount=0 return
begin tran
  update pm_PlanEntry
  set FDispatchQty=t4.FDispatchQty - t1.FDispat ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号