Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix 'error: Error: syntax error - at value'

I have objects like:

address: {
  "phone" : 888,
  "value" : 12
}

And in WHERE i need to find objects by address.value, but in SQL there's function value(), so i always get an error.

I do it from node.js. Are there any variants to solve this without changing objects? Sql request like:

SELECT count(*) as size FROM addresses WHERE address.value = 12
like image 309
Vlad Bespalov Avatar asked Mar 18 '26 22:03

Vlad Bespalov


1 Answers

VALUE is a reserved word. If you want to use it as a common identifier, you need to enclose it in backticks:

SELECT count(*) as size FROM addresses WHERE address.`value` = 12
like image 155
Johan Larson Avatar answered Mar 20 '26 13:03

Johan Larson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!