我目前有
insert into Messages (Content, Sender, Reciever) values (?) SELECT
(SELECT userID FROM Users WHERE Username=?) AS Sender,
(SELECT userID FROM Users WHERE Username=?) AS Reciever;
我有内容要插入内容但我需要做一个选择以获取插入发件人和接收者的内容(是的,我知道这拼写错误)。我如何组合这两个?
答案 0 :(得分:0)
我认为这就是你想要的:
insert into Messages(Content, Sender, Reciever)
SELECT ?,
(SELECT userID FROM Users WHERE Username=?) AS Sender,
(SELECT userID FROM Users WHERE Username=?) AS Reciever;
您不需要values
声明。 insert . . . select
没问题。