?
Solved

Compare query where ID's are different

Posted on 2013-12-21
2
Medium Priority
?
259 Views
Last Modified: 2013-12-21
Hi,

I need help with this query. It is to compare pre conversion data to post conversion data. recno = roid + 2000 (meaning that we added 2000 to the roid so the id's would not hit existing records in the target table.

Here is what I have so far:
SELECT
	`tpsmotorsports source`.`orders money`.recno AS recno,
	`tpsmotorsports target`.ledger.roid,        -- is recno + 2000
	`tpsmotorsports source`.`orders money`.taxamt,
	`tpsmotorsports target`.ledger.amount,
	`tpsmotorsports target`.ledger.transactiontype
FROM
	`tpsmotorsports source`.`orders money`
LEFT JOIN `tpsmotorsports target`.ledger ON `tpsmotorsports source`.`orders money`.recno = `tpsmotorsports target`.ledger.roid
WHERE
	transactiontype = 'RO - Taxes Owed'

Open in new window


For this to work I need to have the join factor in the 2000 increase in the roid value. For example recno 1 will be roid 2001. I am not clear on how to do this and what I have tried has failed. Any idea how to make this work?

Thanks,
c
0
Comment
Question by:ckelsoe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
vr6r earned 2000 total points
ID: 39734146
Have you tried just including the calculation in the join?  Either subtracting 2000 from the roid or adding 2000 to the recno?
Something like this:
LEFT JOIN `tpsmotorsports target`.ledger ON `tpsmotorsports source`.`orders money`.recno = (`tpsmotorsports target`.ledger.roid - 2000)

Open in new window

0
 

Author Comment

by:ckelsoe
ID: 39734154
I did and it returns 0 records. Then I realized I had added 2000 instead of subtract 2000. Another ID10t problem I think.

Thanks for the help!
0

Featured Post

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In this article, we’ll look at how to deploy ProxySQL.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question