Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 952945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:58:22+00:00 2026-05-15T23:58:22+00:00

I have 5 tables and trying to Join into 1 but I am getting

  • 0

I have 5 tables and trying to Join into 1 but I am getting 4 records for each. How can i use correct JOIN statement.

SELECT  tbl_meter.[cdate] AS 'CDate', 
tbl_meter_backup.[machine_no], 
tbl_machines.[accounting_denomination] AS 'Denom', 
(tbl_meter.[turnover]- tbl_meter_backup.[turnover])* tbl_machines.[accounting_denomination]  AS 'Turnover',
(tbl_meter.[total win]- tbl_meter_backup.[total win])* tbl_machines.[accounting_denomination]  AS 'Total win', 
(tbl_meter.[games played]-tbl_meter_backup.[games played]) AS 'Games Played', (tbl_meter.[credit in]-tbl_meter_backup.[credit in]) * tbl_machines.[accounting_denomination] AS 'Credit IN', 
(tbl_meter.[Bill in]-tbl_meter_backup.[Bill in])* tbl_machines.[accounting_denomination]  AS 'Bill In',  
(tbl_meter.[cancel credit]-tbl_meter_backup.[cancel credit])* tbl_machines.[accounting_denomination]  AS 'Cancel Credit', 
tbl_open_backup.[amount] AS 'cgOpen', 
tbl_cancel_backup.[amount] AS 'cgCancel' 
FROM 
tbl_machines, 
tbl_meter,
tbl_meter_backup,
tbl_open_backup,
tbl_cancel_backup  

INNER JOIN tbl_meter  ON 
tbl_meter_backup.[Machine_No] = tbl_meter.[Machine_No] AND tbl_machines.[local_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.[cdate]=@enddate AND tbl_cancel_backup.[cdate]=@enddate;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T23:58:22+00:00Added an answer on May 15, 2026 at 11:58 pm

    First fix your synatx to explicit joins that are easier to read and maintain, there is no excuse for ever using an implicit join, they are error prone and 18 years outdated and especially hard to maintain when you mix them like this. I expect that the system could have been confused on this as well as you didn’t do the joins correctly. In an implicit join, the join criteria goes in the where clause not the on clause of the one explicit join you used. You also joined to the same table twice.

    So with the cleaned up joins do you still have a data issue?

    SELECT  tbl_meter.[cdate] AS 'CDate',  
    tbl_meter_backup.[machine_no],  
    tbl_machines.[accounting_denomination] AS 'Denom',  
    (tbl_meter.[turnover]- tbl_meter_backup.[turnover])* tbl_machines.[accounting_denomination]  AS 'Turnover', 
    (tbl_meter.[total win]- tbl_meter_backup.[total win])* tbl_machines.[accounting_denomination]  AS 'Total win',  
    (tbl_meter.[games played]-tbl_meter_backup.[games played]) AS 'Games Played', (tbl_meter.[credit in]-tbl_meter_backup.[credit in]) * tbl_machines.[accounting_denomination] AS 'Credit IN',  
    (tbl_meter.[Bill in]-tbl_meter_backup.[Bill in])* tbl_machines.[accounting_denomination]  AS 'Bill In',   
    (tbl_meter.[cancel credit]-tbl_meter_backup.[cancel credit])* tbl_machines.[accounting_denomination]  AS 'Cancel Credit',  
    tbl_open_backup.[amount] AS 'cgOpen',  
    tbl_cancel_backup.[amount] AS 'cgCancel'  
    FROM  
    tbl_machines
    INNER JOIN tbl_meter  ON  tbl_machines.[local_no]=tbl_meter.[machine_no] 
    Inner join tbl_meter_backup ON tbl_meter_backup.[Machine_No] = tbl_meter.[Machine_No]
    Inner join tbl_open_backup ON tbl_open_backup.[machine_no]=tbl_meter.[machine_no]
    Inner join tbl_cancel_backup on 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, one or more of your tables has more that one record for the items in the join. This will then need special handling as you need to determine how to know which record you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a three different tables that I'm trying to join up correctly but
Im trying to JOIN 2 tables and count the results. I have these tables;
I have a 3 tables that I'm trying to join and get distinct results.
I have been trying to join two tables (USERS AND USERS_ROLES) based on their
I have got a few tables which I am trying to join. I just
I have the following three tables. I am trying to inter link (join) among
I am trying use gem tire to search in my application. I have tables
I'm trying to simplify some mysql. I have three selects and three tables: SELECT
I have two tables, A and B, and I am trying to select rows
I have 3 tables that I am trying to combine into one with a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.