I have two tables:
Medals and Grocery Store .
I want to bring in just a% of all medals and create a column to put your situation. There would be two statuses, Yes and No .
The structures:
MEDALS
ID
MEDALHA
MEDIA SHOP
ID
NOME
ID_MEDALHA
I'm doing the following SELECT
below:
SELECT
ID_LOJA,
MEDALHAS.ID,
MEDALHA,
CASE LOJA_MEDALHA.ID_MEDALHA
WHEN NULL THEN 'NÃO'
ELSE 'SIM' END AS SITUACAO
FROM
MEDALHAS
LEFT OUTER JOIN
LOJA_MEDALHA
ON
LOJA_MEDALHA.ID_MEDALHA = MEDALHAS.ID OR LOJA_MEDALHA.ID_MEDALHA <> MEDALHAS.ID
WHERE
ID_LOJA = 1
This query is bringing all Yes . Being that I added only one medal to the store.
I want to bring all of them in order to display the medal on or off on my page depending on your status.