我正在尝试使用END AS创建的结果列以及现有的id列创建一个新表。我的查询结果在第一个表中。我想创建一个看起来像第二个的新表。我尝试过多种不同的SELECT INTO方式,但我甚至无法从结果中创建一个新表。
function startRecord(socket) {
console.log("in func");
var userSession = userRegistry.getById(socket.id);
if (!userSession) {
return;
}
var room = rooms[userSession.roomName];
if(!room){
return;
}
var usersInRoom = room.participants;
var data = {
id: 'startRecording'
};
for (var i in usersInRoom) {
console.log("in loop");
var user = usersInRoom[i];
// release viewer from this
user.outgoingMedia.recorderEndpoint.record();
// notify all user in the room
user.sendMessage(data);
console.log(user.id);
}}
答案 0 :(得分:0)
SELECT table1."id",
CASE WHEN table2.val IS NOT null AND table2.val != 'N' THEN table2.val
WHEN table2.val = 'N' THEN null
WHEN table1.val = 'N' THEN null
ELSE table1.val
END AS results INTO New_Table
FROM table1
LEFT JOIN table2 ON table2."id" = table1."id"