我写了一句select语句,形式类似于
select * from table1 where id1 in (select id2 from table2);
1.如果我把后一个子句改成具体的值,比如1234也就是
select * from table1 where id1 in (1234);很快就能出结果
2.如果我直接运行后一个子句也能很快出结果
select id2 from table2; 结果就是1234
但是这样放在一起就很久也不出结果,我不知道是哪里出了问题。
所以我想问一下大家
一、select id2 from table2 返回的是一个怎样的结果是一个表么?
二、是不是跟id1和id2之间的关系比如变量类型(我设置的都是bigint)还有是否primary key有关系?
如果有需要我可以把具体的代码发上来
困扰了很久了。

解决方案 »

  1.   

    我也觉得没有问题,你看看原来的句子
    select * from user_info
    where uid in 
    select follower_id from test t left join user_info u on u.uid = t.uid where flag = 0;
    我只运行最后一个子句出来一个数字,然后我运行
    select * from user_info
    where uid in (数字)
    也能很快出结果。。你觉得有啥问题么
      

  2.   

    select * 
    from table1,table2
    where table1.id1=table2.id2
    如果不考虑重复记录的话,可以使用上述语句。
      

  3.   

    update user_info set flag = 2 where uid in
    (select follower_id from user_view u,test t where u.uid = t.uid and u.flag = 1);
    我改了一下,依然是后半句能够自己运行,但是整句句子不能运行。应该怎样修改?
      

  4.   

    update user_info set flag = 2 where uid in
    (select follower_id from user_view u,test t where u.uid = t.uid and u.flag = 1);update user_info A,user_view u,test t
    set A.flag=2
    where A.uid=follower_id and u.uid = t.uid and u.flag = 1;