ad.hasareli

Well-known member
  • Mar 27, 2010
    5,264
    580
    113
    දකුනේ කොල්ලෙක්
    Good mrng machanla....

    Lokuma loku help akak oni wela tamai me tread aka danne SQL danne netnam plz bump akak wath dila support akak denna.... :)


    Menna mekai wenna oni,
    Akama billno aken table 3ma value thiyenawa nam table 3ma value display karanna ona...akama billno aken table 2ka witarai nam valuve thiyenne a table 2 display karala anith table ake valuwe Null widihata display karanna oni (sometime akama billno aken value thiyenna puluwan 1 table akaka witak wennath puluwan ehema unoth anith table 2kema valuve Null widihata display karanna ona)....
    :(:( yatin mama table 3 screen short 3k attach karanawa :)

    Ane mata onna okata SQL akak liyala dennako plz loku help akak.:yes::yes:

    3.jpg


    2.jpg


    1.jpg
     
    Last edited:
    • Like
    Reactions: lakshithalcr

    hirushan

    Member
    May 21, 2007
    5,957
    32
    0
    40
    Edinton Furniture->Moratumulla
    Code:
    CREATE TABLE table1(
    billno int,
    billinfo varchar(50)
    )
    
    CREATE TABLE table2(
    billno int,
    billinfo varchar(50)
    )
    
    CREATE TABLE table3(
    billno int,
    billinfo varchar(50)
    )
    
    --3 Tables
    Insert into table1 values (1111,'Marie')
    Insert into table2 values (1111,'Marie')
    Insert into table3 values (1111,'Marie')
    
    --Only 2 Tables
    Insert into table1 values (1112,'Hirushan')
    Insert into table2 values (1112,'Hirushan')
    
    --Only 1 
    Insert into table1 values (1113,'Eranga')
    
    select * from table1
    select * from table2
    select * from table3
    
    --All 3
    select table1.billno as [table1-BillNo],
    	   table1.billinfo as [table1-BillInfo],
    	   table2.billinfo as [table2-BillInfo],
    	   table3.billinfo as [table3-BillInfo] 
    from table1
    INNER JOIN table2 
    	ON table1.billno=table2.billno
    INNER JOIN table3
    	ON table1.billno=table3.billno
    
    
    --2 only
    select table1.billno as [table1-BillNo],
    	   table1.billinfo as [table1-BillInfo],
    	   table2.billinfo as [table2-BillInfo],
    	   table3.billinfo as [table3-BillInfo] 
    from table1
    INNER JOIN table2 
    	ON table1.billno=table2.billno
    LEFT JOIN table3
    	ON table1.billno=table3.billno
    
    --only 1
    select table1.billno as [table1-BillNo],
    	   table1.billinfo as [table1-BillInfo],
    	   table2.billinfo as [table2-BillInfo],
    	   table3.billinfo as [table3-BillInfo] 
    from table1
    LEFT JOIN table2 
    	ON table1.billno=table2.billno
    LEFT JOIN table3
    	ON table1.billno=table3.billno
     

    ad.hasareli

    Well-known member
  • Mar 27, 2010
    5,264
    580
    113
    දකුනේ කොල්ලෙක්
    Code:
    CREATE TABLE table1(
    billno int,
    billinfo varchar(50)
    )
    
    CREATE TABLE table2(
    billno int,
    billinfo varchar(50)
    )
    
    CREATE TABLE table3(
    billno int,
    billinfo varchar(50)
    )
    
    --3 Tables
    Insert into table1 values (1111,'Marie')
    Insert into table2 values (1111,'Marie')
    Insert into table3 values (1111,'Marie')
    
    --Only 2 Tables
    Insert into table1 values (1112,'Hirushan')
    Insert into table2 values (1112,'Hirushan')
    
    --Only 1 
    Insert into table1 values (1113,'Eranga')
    
    select * from table1
    select * from table2
    select * from table3
    
    --All 3
    select table1.billno as [table1-BillNo],
           table1.billinfo as [table1-BillInfo],
           table2.billinfo as [table2-BillInfo],
           table3.billinfo as [table3-BillInfo] 
    from table1
    INNER JOIN table2 
        ON table1.billno=table2.billno
    INNER JOIN table3
        ON table1.billno=table3.billno
    
    
    --2 only
    select table1.billno as [table1-BillNo],
           table1.billinfo as [table1-BillInfo],
           table2.billinfo as [table2-BillInfo],
           table3.billinfo as [table3-BillInfo] 
    from table1
    INNER JOIN table2 
        ON table1.billno=table2.billno
    LEFT JOIN table3
        ON table1.billno=table3.billno
    
    --only 1
    select table1.billno as [table1-BillNo],
           table1.billinfo as [table1-BillInfo],
           table2.billinfo as [table2-BillInfo],
           table3.billinfo as [table3-BillInfo] 
    from table1
    LEFT JOIN table2 
        ON table1.billno=table2.billno
    LEFT JOIN table3
        ON table1.billno=table3.billno


    terune nam nehe machan...check ur pm
     

    wsvperera

    Active member
  • Jan 7, 2007
    706
    147
    43
    select *
    from Bill B,Rotation R, Return+item RI
    where B.billno = R.billno

    union

    select *
    from Bill B,Rotation R, Return+item RI
    where RI.billno = R.billno

    union

    select *
    from Bill B,Rotation R, Return+item RI
    where B.billno = RI.billno
     
    • Like
    Reactions: ad.hasareli

    ltty head

    Well-known member
  • May 28, 2009
    3,683
    647
    113
    i think this will help you up with few modifications.. to return null instead of dash (-). depend on ur database you may use isnull() function..

    select a.billno, a.billinfo,b.billinfo,c.billinfo from table1 a full join table2 b on a.billno=b.billno full join table3 c on b.billno=c.billno;


    hellolk.jpg


    please note: this is with reference to the tables given by hirushan
     
    • Like
    Reactions: ad.hasareli