create table tb ( a int, b int, )insert into tb values(1,1) insert into tb values(2,3) insert into tb values(1,1) insert into tb values(2,3) insert into tb values(4,5) insert into tb values(1,1) select tb.* from tb join ( select tb.a,count(0) as x from tb group by tb.a )qq on tb.a=qq.a where qq.x<>1
select stuid,stuname from stuinfo group by stuid,stuname having(count(*))>1
select a,b,count(*) from a group by a,b
select tb.* from tb join ( select tb.a,count(0) as x from tb group by tb.a )qq on tb.a=qq.a where qq.x<>1tb.*from不太懂牙 ??什么意思?
就是tb的* 一样的东西 不然qq这个临时表的东西也出来了
IF NOT EXISTS(SELECT * FROM a WHERE a.a= AND a.b=) INSERT INTO...
create table tb
(
a int,
b int,
)insert into tb values(1,1)
insert into tb values(2,3)
insert into tb values(1,1)
insert into tb values(2,3)
insert into tb values(4,5)
insert into tb values(1,1) select tb.* from tb join
(
select tb.a,count(0) as x
from tb
group by tb.a )qq on tb.a=qq.a
where qq.x<>1
select stuid,stuname from stuinfo
group by stuid,stuname
having(count(*))>1
(
select tb.a,count(0) as x
from tb
group by tb.a )qq on tb.a=qq.a
where qq.x<>1tb.*from不太懂牙 ??什么意思?
INSERT INTO...
但是我看不太懂?
2个select我都不知道执行的那个?
大哥 ,可以解释清楚写不?
2个表一起做联合查询的 第二个表是一个我自己建的表X是代表所有a字段的个数 然后这个个数不为0为条件
也就是说第二个表是一个查询A字段个数的表
2个表联合查询的条件是那第二个表的X的个数不为1
所以就出来了
确实没有学 联合查询?虚构一张表的格式是:
(
select tb.a,count(0) as x
from tb
group by tb.a )qq?