Pages

Sunday 6 July 2014

Diffrent Type of Joins and Linked Type in AX 2009



Car Table

CarId
ModelYear
CarBrand
Model
Mileage
ModelYear
CarId
CA101
2008
Mahindra
Scorpio
15
2008
CA101
CA102
2009
Suzuki
800
12
2009
CA102
CA103
2007
Hundai
i20
5
2007
CA103
CA104
2007
Toyato
Inova
3
2007
CA104
CA105
2009
BMW

5
2009
CA105
CA106
2010
Benz
AZ12
10
2010
CA106


Rental Table
RentalId
CustAccount
CarId
FromDate
ToDate
ToDate
FromDate
RE101
1104
CA101
10/12/2010
10/29/2010
10/29/2010
10/12/2010
RE102
1102
CA102
11/17/2010
12/14/2010
12/14/2010
11/17/2010
RE103
1203
CA103
11/24/2010
12/15/2010
12/15/2010
11/24/2010
RE104
1301
CA104
12/10/2010
1/5/2011
1/5/2011
12/10/2010
RE105
1304
CA101
1/3/2011
1/18/2011
1/18/2011
1/3/2011
RE108
1303





RE107
1202





RE106
2024
CA103
1/10/2011
1/29/2011
1/29/2011
1/10/2011


Inner Join
Select records from main table that have matching record form join table.

Main table record and join table records are joined together  and show as single record.

Code                                                                                                              

static void JoinExamples(Args _args)                                                                        

{                                                                                  

    CarTable carTable;                                                                        

    RentalTable rentalTable;                                                                           

    ;                                                                              

    while select carTable join rentalTable                                                                              

        order by carTable.CarId                                                                        

        where carTable.CarId == rentalTable.CarId                                                                             

                                                                                   

        {                                                                          

            info(strfmt("Car id is %1 renatla id is %2",carTable.CarId, rentalTable.RentalId));                                                                         

        }                                                                          

}

           
Output                                                                       


No comments:

Post a Comment