简体   繁体   English

Have / where子句中的未知列

[英]Uknown column in having/where clause

I am not sure if this error lies within my code or within my MySQL table configuration. 我不确定这个错误是在我的代码中还是在我的MySQL表配置中。 - I have tried using WHERE and HAVING and I have also made the HOSTNAME primary/index key within the table. -我尝试使用WHEREHAVING并且在表中也设置了HOSTNAME主键/索引键。 - Always the same error. -总是相同的错误。

Unknown column 'HOSTNAME' in 'having/where clause' “具有/ where子句”中的未知列“ HOSTNAME”

Note: HOSTNAME is actually my machine hostname, so that's parsed properly. 注意:HOSTNAME实际上是我的计算机主机名,因此已正确解析。

The line of code: 代码行:

Dim Query As String = "SELECT `HOSTNAME`, `UPDATED` FROM `" & device_1_table & _
    "` WHERE HOSTNAME = `" & device_1_column & "`"

Where do I need to look? 我需要看哪里?

I am guessing that the variable device_1_column is set to HOSTNAME . 我猜想变量device_1_column设置为HOSTNAME You need single quotes, not back ticks, for string literals. 对于字符串文字,您需要单引号而不是反引号。 So change this portion of the code: 因此,更改代码的这一部分:

WHERE HOSTNAME = `" & device_1_column & "`

to

WHERE HOSTNAME = '" & device_1_column & "'
-----------------^ ----------------------^

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM