Correia JPV
Correia JPV

Reputation: 610

Query error #1241

SELECT id from reparacoes WHERE id_reparacao 
IN (select DISTINCT re.id_reparacao 
FROM reparacoes re 
WHERE(edit_user="loja cascais" AND estado="Fechada" AND edit_data = (SELECT edit_data, id FROM reparacoes WHERE id_reparacao=re.id_reparacao ORDER BY edit_data DESC LIMIT 1)))

While querying with phpmyadmin, it gives me this error:

#1241 - Operand should contain 1 column(s)

Upvotes: 1

Views: 285

Answers (1)

Alma Do
Alma Do

Reputation: 37365

Your problem is here:

edit_data = (SELECT edit_data, id FROM reparacoes WHERE id_reparacao=re.id_reparacao ORDER BY edit_data DESC LIMIT 1)

you can not compare scalar field with something that have more than one column (i.e. is non-scalar, but row).

I guess correct is:

edit_data = (SELECT edit_data FROM reparacoes WHERE id_reparacao=re.id_reparacao ORDER BY edit_data DESC LIMIT 1)

Upvotes: 3

Related Questions