Select in 3 tables returning multiple Oids

Asked

Viewed 33 times

0

Script only works by returning a single codpro (4609), needed it to return several

inserir a descrição da imagem aqui

SELECT a.filial, a.codpro, b.descricaolonga , a.quant, a.estminimo, c.filial AS 'filial ped', c.quant AS 'carteira', c.quantrec AS 'recebido'
FROM ITEMFILEST a, COMPLEMENTOPRODUTO b , ITEMFORCAD c
WHERE a.codpro = b.codpro AND a.codpro = c.codpro AND c.quantrec ='0.000' and

    a.codpro ='04609'

need it to work with a list:

  • a. codpro ='04609'
  • a. codpro ='04610'
  • a. codpro ='04611' and so on...
  • Tried to use conjunction OR in its clause WHERE? Depending on the amount of values maybe IN be of use to you.

  • The result does not match the data: check column [affiliate Ped] in the result.

  • And how is the junction between tables A and C? Use only the column codpro does not guarantee the result.

  • with a.codpro only ='04609' works fine, but I need to insert more a.codpro ='04609' a.codpro ='04610' a.codpro ='04611'

2 answers

0

The script returns only the codpro value (4609) as it is specified at the end of the WHERE clause that it should do this. Try to remove the and a.codpro ='04609' and see if the result is as expected.

SELECT a.filial, a.codpro, b.descricaolonga , 
a.quant, a.estminimo, c.filial AS 'filial ped', 
c.quant AS 'carteira', c.quantrec AS 'recebido'
FROM ITEMFILEST a, COMPLEMENTOPRODUTO b , ITEMFORCAD c
WHERE a.codpro = b.codpro AND a.codpro = c.codpro AND c.quantrec ='0.000'

By the way the select was written, I believe you are a beginner. That’s why I recommend the study of junctions and groupings, will be very useful to you.

  • Yes, I’m a beginner. I need a code list in addition to this 4609. I need to add more. If I simply remove, it will show all registered items

0

Maybe this will bring the expected return:

SELECT a.filial, a.codpro, b.descricaolonga , a.quant, a.estminimo, c.filial AS 'filial ped', c.quant AS 'carteira', c.quantrec AS 'recebido'
FROM ITEMFILEST a
INNER JOIN COMPLEMENTOPRODUTO as b on a.codpro = b.codpro
INNER JOIN ITEMFORCAD  as c on a.codpro = c.codpro
WHERE c.quantrec ='0.000'
  • Vittoria, your answer seems to have worked!! However it was missing the "c.Quant AS 'wallet'". Where do I include it? Thank you very much already!

  • hi, you put in the select rows that are your columns `SELECT a.branch, a.codpro, b.descricaolonga , a.Quant, a.estminimo, c.filial AS 'affiliate', c.Quant AS 'wallet', c.quantrec AS 'received' and then go the rest

  • I edited to better understand

  • Thank you Vittoria, solved my problem :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.