Match multiple columns with same value SQL

前端 未结 2 505
我在风中等你
我在风中等你 2021-01-19 23:47

Suppose the table has columns like akey1 , bkey2 , ckey3 and many more like it.
Is there way to search for a common value

2条回答
  •  遥遥无期
    2021-01-19 23:57

    You can also try this approach

    ALTER PROCEDURE USP_GetClinicNameList
    	 
    	 @SearchStr varchar(50)
    AS
    BEGIN
    
    SET @SearchStr = RTRIM(@SearchStr) + '%'
    
    SELECT TOP (10)
    	*
    FROM clinic c
    WHERE c.cclinicname LIKE @SearchStr
    OR c.caddress1 LIKE @SearchStr
    OR c.caddress2 LIKE @SearchStr
    OR c.ccity LIKE @SearchStr
    OR c.cstate LIKE @SearchStr
    OR c.cclinicid LIKE @SearchStr
    OR c.czip LIKE @SearchStr
    OR c.ccliniccode LIKE @SearchStr
    OR c.cphone LIKE @SearchStr
    ORDER BY c.cclinicname
    
    END
    GO

    hope it will be more understandable.

提交回复
热议问题