目录:
1. Every derived table must have its own alias
内容:
1. Every derived table must have its own alias
SELECT app, s, ( SELECT COUNT(1) FROM sessions AS b WHERE s >= starttime AND s < endtime ) AS COUNT FROM ( SELECT DISTINCT app, starttime AS s FROM sessions ) AS b
注意红色加粗代码“AS b”,每个派生出来的表都必须有一个自己的别名,加个别名就可以了。
2. 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
报这个错因为创建存储过程的时候少了红框的内容:
3. No database selected
错误代码: 1046 No database selected
此错原因是没有选择数据库
4. Not unique table/alias: 'dept_manager'
# 错误SQL SELECT * FROM dept_manager, dept_manager; # 正确SQL SELECT * FROM dept_manager AS a, dept_manager AS b;
表dept_manager与自己级联时,要指定别名,不然会报此错误。