SQL - AS - 表不存在 - 1146
我的查询是:
SELECT temp.pid FROM
(SELECT postid, date FROM swapping AS s, post AS p
WHERE s.mid='2' AND p.postid=s.postid) AS temp
WHERE temp.date = (SELECT MAX(date) FROM temp)
我收到 #1146 - 表“databasename.temp”不存在
我怎样才能使其工作? 谢谢。
My query is:
SELECT temp.pid FROM
(SELECT postid, date FROM swapping AS s, post AS p
WHERE s.mid='2' AND p.postid=s.postid) AS temp
WHERE temp.date = (SELECT MAX(date) FROM temp)
I receive #1146 - Table 'databasename.temp' doesn't exist
How can I make it work?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看起来你想选择最后一个“pid”,就“日期”而言,其中 s.mid='2'
尝试这个(在你弄清楚 pid 来自哪里并更正第一行之后)
你可能还需要按行排序中的日期列的别名。
It seems like you want to select the last "pid", in terms of "date", where s.mid='2'
Try this (after you figure out where pid comes from and correct the first line)
You might also need to alias the date column in the order by line.
我认为你的专栏不正确......
应该是
I think you have your column incorrect...
should be
@DRapp 至少击中要害。您没有在您引用为临时的子选择中选择“pid”(如果该列存在于交换表或帖子表中),因此它会在那里引发某种类型的错误。
@DRapp hit the nail on the head at least. You haven't selected 'pid' (if that column exists in either the swapping or post table) in your sub selection that your referring to as temp so it would throw some type of error there.