I am trying to find a way to query values in two different columns in the same table, where instances in which the value of columnB does not contain the value of columnA will be indicated in the result set.
For example, my Nodes table contains the NodeName and DNS columns. The values should look something like this:
NodeName DNS Router1 Router1.mydomain.com
I want to run a query to show which rows have a DNS value that does not contain (or does not start) the value of the NodeName field. I think the query should have something similar to the following, but obviously I'm missing something regarding the use of “Like” in this situation.
SELECT NodeName, DNS WHERE DNS NOT LIKE 'NodeName%'
I am using SQL Server 2005 and any suggestions would be greatly appreciated ... :)
source share