MySQL Forums
Forum List  »  PHP

If selection results in too many rows
Posted by: Vemsom Helst
Date: June 02, 2017 09:39AM

Hi!
My Googling didnt give results on this issue as Im not sure what to Google on.
I have this query:
SELECT
A.VBELN AS SALES_DOCUMENT
,A.POSNR as ITEM
,if(D.GEGRU='EU', D.ALNUM,'0') as EU
,if(D.GEGRU='US', D.ALNUM,'0') as US
,if(D.GEGRU='E1', D.ALNUM,'0') as E1
FROM TABLE1 A
LEFT JOIN TABLE2 D on A.MATNR=D.MATNR and D.ALAND='BE'

Result is in this format:
SALES_DOCUMENT / ITEM / EU / US / E1
000156 / 001 / EU / 0 / 0 /
000156 / 001 / 0 / US / 0 /
000156 / 001 / 0 / 0 / E1 /
003344 / 005 / EU / 0 / 0 /
003344 // 005 / 0 / US / 0 /

But what I want is this:
SALES_DOCUMENT / ITEM / EU/ US/ E1
000156 / 001 / EU / US / E1 /
003344 / 005 / EU / US / 0 /

I want the results per one row, not split per EU/US/E1. Thanks for any help =)

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.