我建立了三个表,table1,table2,table3!
在table2与table3连接执行查询的出用户名字段记录为
userid
a
a
a
b
b
把查询的到userid的记录个数添加到在table1中相应userid的number字段中!
不知道这样的sql语句该怎么写!
请问能不能帮帮我谢谢!

解决方案 »

  1.   

    --假设table2 和 table3 连表查询的结果为 tab_nameupdate table1 
    set number = 
    (select count(*) from tab_name
      where userid = table1.userid) 
    where exists (select 1 from tab_name where userid = table1.userid)
      

  2.   

    update table1 
    set number = 
    (select count(*) from (select table2.userid tt from table2 ,table3 where table2.userid=table3.userid) b
      where b.tt= table1.userid) 表b的形成根据你的实际条件....