Text search problem

  • Hi

    I want to search text in this way:

    USE Northwind

    SELECT * FROM employees WHERE firstname like '%' + (SELECT Distinct

    LEFT(ContactName,3) FROM customers WHERE LEFT(ContactName,2) = 'AN') + '%'

    --

    but I get error msg:

    Subquery returned more than 1 value. This is not permitted when the subquery

    follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

    So i got that LIKE is for string is there a way to search with Subquery???

  • Something like this?

    Select col1, col2 from dbo.Employees E inner join dbo.Customers C on E.FirstName like '%' + LEFT(C.ContactName, 3) + '%' and LEFT(C.ContactName, 3) = 'AN'

  • Very Good!  ... just a minor slip

    Select col1, col2 from dbo.Employees E inner join dbo.Customers C on E.FirstName like '%' + LEFT(C.ContactName, 3) + '%' and LEFT(C.ContactName, 2) = 'AN'


    * Noel

  • Just wanted to see if you guys were paying attention .

  • Thanks

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply