insert into t_user_and_friend(userId, friendId, notename, friendTypeId) 
values(
select uf.id userId, ut.id friendId, ifd.notename, ifd.friendType friendTypeId 
from t_news n 
left join t_invite_friend_dynamic ifd on n.resourceId = ifd.id 
left join t_interactivenews inte on n.id = inte.newsId 
left join t_user uf on n.actorId = uf.id 
left join t_user ut on inte.reminderId = ut.id 
where n.id = 782)
我从另外几张表中查出记录然后插入到t_user_and_friend表,为什么插不进去呢?
错误信息如下:
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 uf.id, ut.id, ifd.notename, ifd.friendType from t_news n left join t_invi' at line 1

解决方案 »

  1.   

    这是你的原语句吗????建议直接贴你的语句,不做任何改动。near 'select uf.id, ut.id, ifd.notename, ifd.friendType from t_news n left join t_invi' at line 1
    这里可以看出和你贴出的语句完全不是同一个语句。
      

  2.   


    insert into t_user_and_friend(userId, friendId, notename, friendTypeId) 
    select uf.id userId, ut.id friendId, ifd.notename, ifd.friendType friendTypeId 
    from t_news n 
    left join t_invite_friend_dynamic ifd on n.resourceId = ifd.id 
    left join t_interactivenews inte on n.id = inte.newsId 
    left join t_user uf on n.actorId = uf.id 
    left join t_user ut on inte.reminderId = ut.id 
    where n.id = 782)
      

  3.   


    insert into t_user_and_friend(userId, friendId, notename, friendTypeId) 
    select uf.id userId, ut.id friendId, ifd.notename, ifd.friendType friendTypeId 
    from t_news n 
    left join t_invite_friend_dynamic ifd on n.resourceId = ifd.id 
    left join t_interactivenews inte on n.id = inte.newsId 
    left join t_user uf on n.actorId = uf.id 
    left join t_user ut on inte.reminderId = ut.id 
    where n.id = 782;