I am Bish
I am Bish

Reputation: 175

Sql Server 2012 (T-SQL) String Comparison (for equality) gives asterisk in query results

I am comparing two strings from different tables for equality using:

WHERE OMRBuildingSurveys.PublishedOwner != OwnershipEntities.Name

I want to exclude all results where the two strings are equal in my query results. However, where the strings are equal they are still being displayed but for some reason there is an asterisk in the query results as you can see in the results shown here

PublishedOwner          Owner Name
Seymour Developments    Unknown
Westpac Bank            Westpac Bank *

I have tried casting both strings to varchars and nvarchars and it doesn't seem to affect the results.

If anyone could tell me what I'm missing. I'd be hugely grateful.

Upvotes: 2

Views: 1040

Answers (1)

M.Ali
M.Ali

Reputation: 69504

You can try something like this.

SELECT Column1, Column2, Column3
FROM OMRBuildingSurveys 
WHERE OMRBuildingSurveys.PublishedOwner NOT IN 
                                              (
                                               SELECT OwnershipEntities.Name 
                                               FROM  OwnershipEntities
                                               )           

Upvotes: 1

Related Questions