易截截图软件、单文件、免安装、纯绿色、仅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


相关问答:

linux 下的java 程序调用sqlplus执行.sql文件乱码

                        现在我的情况是这样:

                        我的 ......

java连接sql 2005问题 在线等。。。。


import java.sql.*;

public class Test {
public static void main(String[] srg) {
  String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";  //加载JDBC ......

sql 字符串处理问题 来者有分


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

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


来者有分.

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

REPLACE 不好用 自己试下

SQL code:

declare @s ......

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

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

有两个表。分别都有ID主键。A表的ID和B表的ID是对应的,就是A表几个ID,B表就几个ID。A表的ID是什么,B表的ID就是什么。
可是现在A表的ID比B表的多了。
我现在想要把B表中少的部分给补齐了。这个插入应该怎么写 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号