Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Comparing multiple fields within the same row in a single table

Posted on 2012-08-15
3
Medium Priority
?
550 Views
Last Modified: 2012-08-15
Column A                                 Column B
Lorem Ipsum Tango                Tango

I'm trying to write a query  that will search all rows in Column A and see if they contain the contents of Column B.

This one returned NO rows:
SELECT DISTINCTROW [Table1].[ColumnA]
FROM [Table1]
WHERE ((([Table1].[ColumnA]) Like "*[Table1].[ColumnB]*"));

This one returns all rows with C, O, L, U, M...., or B in them:
SELECT DISTINCTROW [Table1].[ColumnA]
FROM [Table1]
WHERE ((([Table1].[ColumnA]) Like "*[ColumnB]*"));

How to I search for Column B within Column A without it matching exactly?
i.e. *[ColumnB]*

Thank you!
0
Comment
Question by:dgran
  • 2
3 Comments
 
LVL 29

Accepted Solution

by:
IrogSinta earned 2000 total points
ID: 38298730
SELECT DISTINCTROW [Table1].[ColumnA]
FROM [Table1]
WHERE [Table1].[ColumnA] Like "*" & [Table1].[ColumnB] & "*"
0
 

Author Closing Comment

by:dgran
ID: 38298788
I can't believe I didn't think of that!  I've use that before many times.  Mostly for filling a field with the values from multiple fields.
Thank you!
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38298805
Every now and then we all just get a brain fart.  You probably would have figured this out eventually.
 :-)

/Ron
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

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

Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

564 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