Comparing data from one field to several others

estin

New member
Local time
Today, 15:15
Joined
Aug 26, 2013
Messages
3
I have one table A that has a Name field that I would like to find if it matches any of the cases in table B with 2 other fields: Field 1 or Field 2

There is no way of establishing referential integrity because the Name Field can be found in either Field 1 or Field 2.

How would I go about searching so I can pull in the rest of the data that I need with when the Name is matched either with Field 1 or 2?
 
You can use a cartesian join, with something like the following:
Code:
SELECT TableA.*, TableB.*
FROM TableA, TableB
WHERE TableA.Name = TableB.Field1
OR TableA.Name = TableB.Field2;
NOTE: This is not the most performance-friendly option for tables with extremely large amounts of data, but for smaller-sized tables is a perfectly workable option.
 
I tried the above code and got a syntax error.

I'm not sure the best way to explain. I need to wildcard the characters from Table B.Field 1 or Table B.Field 2 to be able to identify if Table A.Name Column has any character matches.
 

Users who are viewing this thread

Back
Top Bottom