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
解决方案 »
- 请教有经验的朋友,谢谢!
- 合并查询
- 这条语句如何写--Mysql
- 关于MySQL在Linux中的问题
- 【30分】问个小小滴问题
- 1)mysql的安装路径:mysql各个组成部分都放在哪个文件夹下,应该如何部署? 2)Mysql启动的时候,它如何知道去哪儿读取配置文件呢?
- 关于mysql分区问题
- Lock wait timeout exceeded; try restarting transaction应如何解决
- VC++ ,应用mysql存储图片并可以读取图片
- 在mysql里有没有类似windows中刷新或foxbase中的ctrl+w的命令
- 如何在mysql存储过程中处理select语句返回的多行结果?
- mysql 联合查询两张表问题
这里可以看出和你贴出的语句完全不是同一个语句。
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)
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;