select a.subject as title, a.itemid as id from table_a as a left join table_s as s on a.itemid = s.itemid;
为什么我在selecct中加入a.itemid 就报错?

解决方案 »

  1.   

    那个itemid是两个表的关联字段,
      

  2.   

    select a.subject as title, a.itemid as id from table_a as a left join table_s as s on a.id = s.itemid;
      

  3.   

    s 有itemid这个字段吗? 
      

  4.   

    1064: 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 'a.itemid as link from 
      

  5.   

    我觉得是你的left join语法有错误。lz自己检查一下例子: SELECT *
      FROM b JOIN a LEFT JOIN c ON (c.key=a.key) LEFT JOIN d ON (d.key=a.key)
      WHERE b.key=d.key;
     
      

  6.   

    select s.subject as title, a.filepath as bUrl, a.thumbpath as sUrl a.itemid as link from notes_attachments a left join notes_spaceitems s on a.itemid = s.itemid order by a.dateline desc
    这是原句把a.itemid as link 去掉能正确查询
      

  7.   

    select s.subject as title, a.filepath as bUrl, a.thumbpath as sUrl,a.itemid as link from notes_attachments a left join notes_spaceitems s on a.itemid = s.itemid order by a.dateline desc
      

  8.   

    select a.subject as title, a.itemid as id 
    from table_a as a left join table_s as s on (a.itemid = s.itemid);