1
I’m trying to assemble a select that has the result below:
With select below I can show the null in just one column. How could I make it work for 20? I have from item_1 to item_20 and the description of the item is in the table of pieces, in occurrences have only his code.
SELECT P1.descricao desc1
FROM ocorrencias
LEFT JOIN pecas P1
ON P1.cod_peccin=ocorrencias.item_1
WHERE ocorrencias.cod = 2
I tried that way with two columns, but it didn’t work:
SELECT P1.descricao desc1, P2.descricao desc2
FROM ocorrencias
LEFT JOIN pecas P1, pecas P2
ON P1.cod_peccin=ocorrencias.item_1, P2.cod_peccin=ocorrencias.item_2
WHERE ocorrencias.cod = 2