Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
Join on tables where values are not equal

I want to join two tables where values match a condition, not where the values are equal to one another. I've looked around, I have no idea how to do this.

Here's an example:

Join Table_1 to Table_2 WHERE NUM1 <= NUM3 AND NUM2 >= NUM4;

Table_1:
ID1|NUM1|NUM2
-------------
AAA|1934|1942
BBB|1935|1943
CCC|1939|1944

Table_2:
ID2|NUM3|NUM4
-------------
HHH|1934|1935
GGG|1935|1939
UUU|1939|1942
FFF|1942|1943
PPP|1943|1944

Join_Result:
ID1|NUM1|NUM2|ID2|NUM3|NUM4
---------------------------
AAA|1934|1942|HHH|1934|1935
AAA|1934|1942|GGG|1935|1939
AAA|1934|1942|UUU|1939|1942
BBB|1935|1943|GGG|1935|1939
BBB|1935|1943|UUU|1939|1942
BBB|1935|1943|FFF|1942|1943
CCC|1939|1944|UUU|1939|1942
CCC|1939|1944|FFF|1942|1943
CCC|1939|1944|PPP|1943|1944

Tried something like this:

SELECT * INTO Join_Result
FROM Table_1 A
JOIN Table_2 B
ON NUM1 <= NUM3 AND NUM2>= NUM4;
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The SQL above was correct.

SELECT * INTO Join_Result
FROM Table_1
JOIN Table_2
ON NUM1 <= NUM3 AND NUM2>= NUM4;
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!