I have 5 tables and I am getting 4 records for each, while trying to join. Join in the statement how can I use the right one Select
tbl_meter. [Cdate] as 'cdate', tbl_meter_backup. [Machine_no], tbl_machines. [Accounting_denomination] as 'Denom', (tbl_meter. [Business] -. Tbl_meter_backup [business]) * tbl_machines [accounting_denomination] 'business', as (tbl_meter [total victory] -..... tbl_meter_backup [Total Win]) * tbl_machines [accounting_denomination] as 'total victory', was played (Tbl_meter [[game] -tibi_mtr_bakap [games played] as 'Game', (Tibimmitr) [credit] -tibi_mtr_bakap. [credit ]] * Tibiel_macinen. [Akounting_demneshn] aS 'credit in "(TBL meters).] -tbl_meter_backup. [bill]) * tbl_machines. In the form of 'accounting_denomination', 'tbl_meter.' [Canceled credit] -tbl_meter_backup. [Credit cancellation] * tbl_machines 'Cancel Credit' as [accounting_denomination], tbl_open_backup. 'CgOpen' as the [zodiac], tbl_cancel_backup. [Amount] as 'cgCancel' tbl_machines, tbl_meter, tbl_meter_backup, tbl_open_backup, tbl_cancel_backup INNER Join tbl_m Eter ON tbl_meter_backup. [Machine_new] = tbl_meter. [Machine_no] and tbl_machines [Machine_no] = tbl_meter [Machine_no] and tbl_open_backup. [Machine_no] = tbl_meter [Machine_no] and tbl_cancel_backup. [Machine_no] = tbl_meter [Machine_no] Where Tbl_meter_backup. [CDate] = @StartDate and tbl_meter [CDate] = @EndDate and tbl_open_backup [Cd] = @adidet and tbl_cancel_backup [CdT] = @eded;
Firstly add your synatx properly, which is easy to read and maintain There are no excuses for using an inherent joining ever, they are prone to error, and to keep them 18 years old and especially difficult when you mix them in this way. I hope this system could be confused with it, and you did not include it correctly. In an inherent involvement, the criteria for joining is that one particular section is not included after you join the use. You too have joined the same table twice.
So with cleanliness, do you have any data problem now?
SELECT tbl_meter [Cdate] AS 'cdate', tbl_meter_backup. [Machine_no], tbl_machines. 'Denom' as [accounting_denomination], (tbl_meter [business] - .. tbl_meter_backup [business]). * Tbl_machines [accounting_denomination] 'business', as (tbl_meter [total wins] - .. tbl_meter_backup [total wins]) * tbl_machines. [Accounting_denomination] as' total victory ', (tbl_meter. [Games played] -tbl_meter_backup. [Games played]) as "game played', (tbl_meter. -tbl_meter_backup [credit]. [Credit]) * Tbl_machines [Accounting_denomination] AS 'credit in', (TBMM) [in bill] -TB_motor_backup. [In bill]) * TBL_Machines [Accounting_Demanation] AS 'Bill In', (TBMM). [Cancel Credit] - Tb_matter_backup [Cancel Credit] * tbl_machines 'Canceled credit' as [accounting_denomination], tbl_open_backup 'CgOpen' as the [zodiac], tbl_cancel_backup. Combine tb_meter based on inner tbl_machines from 'cgCancel' tbl_machines as [zodiac]. [Lo [machine_no] = tbl_meter. [Machine_no] Internal tbl_meter_backup ON tbl_meter_backup. [Machine_new] = tbl_meter. [Machine_new] Join tbl_open_backup on internal tbl_open_backup [Machine_no] = tbl_meter [Machine_no] Join tbl_cancel_backup at the internal tbl_cancel_backup. [Machine_no] = tbl_meter [machine_no] Where tbl_meter_backup [cDate] = @StartDate and tbl_meter [cDate] = @EndDate and tbl_open_backup [cdate] = @ ENDDATE and tbl_cancel_backup [cdate] = @ ENDDATE .... If so, there is a record for items to be included in one or more of your tables. After that you will need special handling, because you need to determine which record you want to know.
Comments
Post a Comment