在MySQL数据库中列名称的连字符 [英] Hyphens in column names in MySQL DB
问题描述
可能这个问题已经回答了,但我找不到它。
May be this question has been answered before but I couldn't find it.
我使用的是一个2/3的MySQL数据库,列名称。当我尝试使用这些名称从我的Java代码,名称断开连字符(例如air_port成为空气),因此找不到。我试着在我的代码中将连字符替换为下划线,希望数据库可以平等对待他们,但这不工作。
I am using a 2/3 yr old MySQL database which has hyphens in its column names. When I try to use these names from my Java code, the names are broken at the hyphen (e.g. air_port becomes air) and thus are not found. I tried replacing hyphens to underscores in my code hoping that the DB might treat them equally but that doesn't work.
如何转义连字符或如何访问这些列?
How can I escape the hyphen or how can I access these columns ? Could this be an issue of the character set being used ?
推荐答案
在back-ticks内包含名称
enclose the names within `back-ticks`
这篇关于在MySQL数据库中列名称的连字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!