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
Solved

join on tables not working as expected MySQL

Posted on 2014-11-19
7
239 Views
Last Modified: 2014-11-30
I am trying to join 2 tables and get the one with the grater date

Select ToolType,SerialNumber,Qty From Temp_MyTools Where FUploadTime > HUploadTime and SerialNumber NOT IN(
select ti.SerialNumber 
From Temp_IDs AS  ti 
LEFT Join Temp_MyTools as tm on tm.serialnumber = ti.serialnumber 
WHERE tm.FUploadTime > ti.UploadDate) 

Open in new window


tm.FUploadDate for 3 records is not  > ti.UploadDate Why is it pulling those serialnumbers in the subselect
0
Comment
Question by:r3nder
  • 5
7 Comments
 
LVL 15

Expert Comment

by:Haris Djulic
ID: 40453992
Hello,

can you post sample data for those 3 records?
0
 
LVL 6

Author Comment

by:r3nder
ID: 40454143
Here are the records in the subselect
Temp-IDs.csv
0
 
LVL 6

Author Comment

by:r3nder
ID: 40454146
here are the records I am comparing them to
Temp-MyTools.csv
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 40

Expert Comment

by:Sharath
ID: 40454330
Can you post the expected result also?
0
 
LVL 6

Author Comment

by:r3nder
ID: 40454351
the expected results should be what is in Temp_MyTools.csv minus what is in  Temp_Ids.csv because the uploaddate in the Temp_MyIDs is greater than the FuploadTime in the Temp_MyTools table
0
 
LVL 6

Accepted Solution

by:
r3nder earned 0 total points
ID: 40454354
Now that I  wrote it out wouldn't it just be this to get those serial numbers
Select ToolType,SerialNumber,Qty From Temp_MyTools Where FUploadTime > HUploadTime and SerialNumber NOT IN(
select ti.SerialNumber 
From Temp_IDs AS  ti 
LEFT Join Temp_MyTools as tm on tm.serialnumber = ti.serialnumber 
WHERE ti.UploadDate > tm.FUploadTime) 

Open in new window

0
 
LVL 6

Author Closing Comment

by:r3nder
ID: 40472367
figured it out myself
0

Featured Post

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Uploading a CSV Data Import via PHP & MySql 3 29
SQL trigger 5 20
RAISERROR WITH NOWAIT 2 14
SQL - Simple Pivot query 8 11
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

809 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