1
Opa,
I have two tables: forma_pagamento
and forma_pagamento_selecionada
.
I have a while where should be listed all forms of payment, so in this while should have a condition IF
where will return me a new column, if, are found equal values between the two tables, example, that did not work.
SELECT
*,
IF(forma_pagamento_selecionado_id = forma_pagamento_id, NULL, 'checked') AS isChecked
FROM
forma_pagamento_selecionado
INNER JOIN
forma_pagamento ON forma_pagamento_id = forma_pagamento_selecionado_id
That is, if the forma_pagamento_selecionado_id
be equal to forma_pagamento_id
, the isCheckd
will receive the value 'checked', if not equal, will not receive value.
Cara gives a read on COALESCE Mysql, does not meet your needs? Because you test the conditions per parameter until you find one that is not null.
– PauloFlesch