user3180885
user3180885

Reputation: 23

MySQL Error #1241

this is my SQL:

UPDATE seg_guidesdata 
SET cash_box=(cash_box-(425,0)) 
WHERE idseg_guidesdata=(SELECT fk_guidedata FROM users WHERE idusers=180);

quite simple, but i get the error

#1241 - Operand should contain 1 column(s).

I understand what the error means, but i dont know why i get it here. The subquery actually return 1 row with 1 column. I checked it:

PHPMyAdmin return of subquery:

enter image description here

So, anybody has an idea why i get this error?

THX

Upvotes: 2

Views: 140

Answers (1)

lc.
lc.

Reputation: 116458

The decimal separator for a literal in an SQL query is the dot (.), regardless of any locale or formatting settings. Therefore you must represent the number 425,0 as 425.0:

UPDATE ... SET cash_box=(cash_box-(425.0)) WHERE ...

The error message is coming from the comma being interpreted as a column separator, which makes (425,0) look like it is two columns.

Upvotes: 1

Related Questions