例如有两个表:table1, table2
table2表的结构是id,tid,address table1表的结构是tid,num
我要做的是select num=count(*),tid from table2 group by tid将得到的相对应的tid,更新table1表的相应的num值
update table1 set num = .....where tid = ....例如记录: table1 表
tid num
1 null
2 null table2表
id, tid, address
1 1 192.121.0.1
2 1 192.121.0.2
3 2 192.155.0.1
结果: talbe1表
tid num
1 2
2 1
请教sql语句怎么写
table2表的结构是id,tid,address table1表的结构是tid,num
我要做的是select num=count(*),tid from table2 group by tid将得到的相对应的tid,更新table1表的相应的num值
update table1 set num = .....where tid = ....例如记录: table1 表
tid num
1 null
2 null table2表
id, tid, address
1 1 192.121.0.1
2 1 192.121.0.2
3 2 192.155.0.1
结果: talbe1表
tid num
1 2
2 1
请教sql语句怎么写
insert into table2 select * from T#
drop table T#