简体   繁体   中英

Uknown column in having/where clause

I am not sure if this error lies within my code or within my MySQL table configuration. - I have tried using WHERE and HAVING and I have also made the HOSTNAME primary/index key within the table. - Always the same error.

Unknown column 'HOSTNAME' in 'having/where clause'

Note: HOSTNAME is actually my machine hostname, so that's parsed properly.

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 . 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 & "'
-----------------^ ----------------------^

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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