book和new分别是两表;
select id from book where id in( select id from new);
返回结果id
         1
        11
但是输入标题sql语句时候,提示you have an error in your sql syntax; check the manual that corresponds to your mysql server version for the right syntax to use near('select id from new') at line 1;

解决方案 »

  1.   

    MYSQL版本?
    select `id` from book where `id` in( select `id` from `new`);
      

  2.   

    select id from book where id in( select id from `new`);
    new 加上反引号`
      

  3.   

    select id from book intersect select id from 'new';
    还是没有结果的
      

  4.   

    select a.id from book a inner join `new` b on a.id=b.id
      

  5.   

    5楼答案是正确的,为什么这里用别名呢?还有能解释下刚才intersect为什么执行不了
      

  6.   

    mysql不支持intersect,别名也可以不用,缩短SQL语句长度