SUB QUERY RETURNED MORE THAN ONE VALUE

  • Hi all,

    I am trying to execute the following query

    SELECT TOP 100 ADDRESSLINE1 FROM MST_ADDRESS WHERE ADDRESSLINE1 LIKE

    (SELECT ''+KEY_WORD+'%' FROM DIGITLOOKUPS.dbo.INPROGRESS_POBOX_EXCLUSION_LOOKUP)

    but striking with an error sub query returned more than one value.

    I understood why and what the error is about , but no idea how to resolve and retrieve the data I want.

    Any help is highly appreciated.

    Thanks

  • SELECT TOP 100 ADDRESSLINE1 FROM MST_ADDRESS WHERE ADDRESSLINE1 in

    (SELECT colName FROM DIGITLOOKUPS.dbo.INPROGRESS_POBOX_EXCLUSION_LOOKUP where colName like ''+KEY_WORD+'%')

    maybe?

  • Thanks for the reply.

    I have tried that way already but is not working.

    All I want is to select a column addressline from a table mst_address where addressline like key_word+'%'. Here key_word is a column in another table called lookup.

    Any help please?

  • SELECT TOP 100 ADDRESSLINE1 FROM MST_ADDRESS ma WHERE EXISTS

    (SELECT 1 FROM DIGITLOOKUPS.dbo.INPROGRESS_POBOX_EXCLUSION_LOOKUP pel WHERE ms.ADDRESSLINE1 LIKE pel.KEY_WORD+'%')

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

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

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