OPa,
I have two tables: forma_pagamento
and forma_pagamento_selecionada
.
I have a while where all forms of payment should be listed, so in this while you must have a IF
condition where a new column will return me, in case, equal values are found between the two tables, It worked.
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 forma_pagamento_selecionado_id
is equal to forma_pagamento_id
, isCheckd
will get checked, if it is not equal, it will not receive value.