Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Value of one field existing in another

Author  Topic 

rcr69er
Constraint Violating Yak Guru

327 Posts

Posted - 2007-11-26 : 06:16:22
Hi

I am trying to find a way of finding if the value in one field exists in another.

I am using the following query which doesnt seem to be giving the correct result.

SELECT
Forenames
,Company
FROM Details
WHERE Forenames LIKE [Company] + '%'


Does anyone have any other solutions

Thanks

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-11-26 : 06:18:03
SELECT
Forenames
,Company
FROM Details
WHERE Forenames LIKE '%' + [Company] + '%'


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

rcr69er
Constraint Violating Yak Guru

327 Posts

Posted - 2007-11-26 : 06:24:41
Hi
Thanks for that, When running the query I'm still getting cases where there is a value in the forename column but no value in the company column.
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2007-11-26 : 06:46:37
Add

And Company is not null.
Go to Top of Page
   

- Advertisement -