473,395 Members | 1,885 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Multiple joins as an "OR"

I have two tables, one has two phone fields and the other has four phone fields. Everything is standardized to 10 digits per field and I import them as text.

Is it possible to join them based on whether Table1.Phone1 matches ANY of Table2.Phone1, Table2.Phone2, Table2.Phone3, or Table2.Phone4 AND a one to one relationship of another field?

I know I would likely have to do a second query for Table1.Phone2 to ANY of the Table2 phone fields.

Table1:
Name - Phone1 - Phone2
John Smith - 2125551212 - 7185551212
Bob Adams - 3015551212 - 4105551212

Table2:
ID - Name - Phone1 - Phone2 - Phone3 - Phone4
123 - John Smith - 2125551212 - null - null - 7185551212
456 - Bob Adams - null - 4105551212 - null - null

Desired Result would be a mix of fields from both tables. For example:
Table2.ID Table1.Phone1 Table2.Phone2 etc.

Thanks in advance!
Jul 19 '08 #1
1 1240
r035198x
13,262 8TB
OR should do it for the firstpart. Something like
Expand|Select|Wrap|Line Numbers
  1. select  t2.ID, t1.Phone1, t2.Phone2  from Table1 t1, Table2 t2
  2. where (t1.Phone1 = t2.Phone1 or  t1.Phone1 = t2.Phone2 or t1.Phone1 = t2.Phone3 ....)
  3. AND ...
Jul 21 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: tdi | last post by:
Ok, stupid question for the day. I'm reading the interview with Steve Moret and he says: "Once a lot of scripts started going in we knew there was no way we could back out of using Python." I'm...
3
by: Sara Khalatbari | last post by:
Hi! Suppose you're writing a module & writing the definition of each function in that module in " or """. for example: a) "This function does this & that" or: b) """This function does blah...
40
by: Steve Juranich | last post by:
I know that this topic has the potential for blowing up in my face, but I can't help asking. I've been using Python since 1.5.1, so I'm not what you'd call a "n00b". I dutifully evangelize on the...
3
by: Colleyville Alan | last post by:
I am constructing a SQL command from a function. Some code builds the WHERE clause in a looping structure and passes that as an argument to the SQL-building function. But the results do not...
0
by: Greg Strong | last post by:
Hello All, In the past I've used a combo box with the 'row source' being an Access SQL union query to select "All" or 1 for only 1 criteria in a query. An example is as follows: SELECT 0 As...
12
by: junky_fellow | last post by:
Which is better using a switch statement or the if-then equivalent of switch ?
5
by: han zhiyang | last post by:
Hi. I tried to design a custom web control which can flexibly and dynamicly let the control user ,for example the web page developer, customize its layout codes.This control derives from...
2
by: Sheldon | last post by:
In the code below, it seems like there should be a way to simplify the expression to search for the specific values of 1, 9, 10, 11 and 12. It would be more tedious if I was looking to execute some...
1
by: LindaOSU | last post by:
I have data coming into several tables (from emails leads, contact us forms, phone leads, sales etc). I need to create a report that shows a connection from the sales table back to emails or phone...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.