Herewith I used Northwnd database, i trigger same with contactname .
try this code it will work fine.
SELECT [Customers].ContactName,[Customers].[City] FROM [Customers], (Select ContactName,SUBSTRING(ContactName, 0, CHARINDEX(' ', ContactName)) AS toMatch
FROM [Customers]) as otherOne
WHERE
SUBSTRING([Customers].ContactName, 0, CHARINDEX(' ', [Customers].ContactName)) = otherOne.toMatch
and [Customers].ContactName <> otherOne.ContactName
Mark as Answer if its help.
Ravi_D
Participant
1212 Points
270 Posts
Re: Reterving data from database??
Jul 05, 2011 11:59 AM|LINK
Hi,
Herewith I used Northwnd database, i trigger same with contactname .
try this code it will work fine.
SELECT [Customers].ContactName,[Customers].[City] FROM [Customers], (Select ContactName,SUBSTRING(ContactName, 0, CHARINDEX(' ', ContactName)) AS toMatch FROM [Customers]) as otherOne WHERE SUBSTRING([Customers].ContactName, 0, CHARINDEX(' ', [Customers].ContactName)) = otherOne.toMatch and [Customers].ContactName <> otherOne.ContactName Mark as Answer if its help.D.Ravi