微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

mysql – select中是否存在星号排除其他列?

这个问题都是关于懒惰……我想做这样的事情:

select some_func(some_col), * from my_table

所以我不必这样做:

select some_func(some_col), col_1, col_2... col_ad_infinitum from my_table

有没有办法让第一个查询工作?这是我运行时遇到的错误

ERROR 1064 (42000) at line 1: 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 '* from my_table' at line 1

解决方法:

你的意思是在MysqL你的第一个查询

SELECT some_func(some_col), * 
FROM my_table

产生这个错误?:

Error Code: 1064. 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 ‘*’ at line 1

@H_502_41@

您可以将代码更改为(这样可以避免错误!):

SELECT *, some_func(some_col) 
FROM my_table

或者,如果您想先计算列,请执行此操作:

SELECT some_func(some_col), t.* 
FROM my_table AS t

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐