locked
sql query to check 's RRS feed

  • Question

  • hi

    i have name like david's  i need to check this in where clause or with like

    how to do it in sql

    Friday, February 1, 2013 3:06 PM

Answers

  • You just double up the single quote:

    Declare @tvTable Table (
    	DataCol varchar(10)
    )
    
    Insert	@tvTable
    Values	('blip'), ('blop'), ('flip''s'), ('flop''s')
    
    Select	*
    From	@tvTable
    Where	DataCol Like '%''%'

    • Proposed as answer by Naomi N Friday, February 1, 2013 9:50 PM
    • Marked as answer by Kalman Toth Sunday, February 10, 2013 10:11 AM
    Friday, February 1, 2013 3:12 PM

All replies

  • DECLARE @tab TABLE(NAME VARCHAR(10))
    INSERT INTO @tab
    SELECT 'abc''s' UNION ALL
    SELECT 'abcdef''s' UNION ALL
    SELECT 'lmn''s' UNION ALL
    SELECT 'pqr''s'
    SELECT * FROM @tab
    SELECT *
    FROM @tab
    WHERE NAME LIKE 'abc''s'


    Narsimha

    Friday, February 1, 2013 3:12 PM
  • You just double up the single quote:

    Declare @tvTable Table (
    	DataCol varchar(10)
    )
    
    Insert	@tvTable
    Values	('blip'), ('blop'), ('flip''s'), ('flop''s')
    
    Select	*
    From	@tvTable
    Where	DataCol Like '%''%'

    • Proposed as answer by Naomi N Friday, February 1, 2013 9:50 PM
    • Marked as answer by Kalman Toth Sunday, February 10, 2013 10:11 AM
    Friday, February 1, 2013 3:12 PM
  • itas not  like that

    its  like  abc's product,

    abced's product

    something liek this

    Friday, February 1, 2013 3:13 PM
  • select * from person where lastname = 'david''s' select * from person where lastname like '%''%'


    Friday, February 1, 2013 3:13 PM
  • itas not  like that

    its  like  abc's product,

    abced's product

    something liek this

    Try

    SELECT *
    FROM @tab
    WHERE NAME LIKE ('abc''s%')


    Narsimha

    Friday, February 1, 2013 3:21 PM
  • SELECT * FROM yourtable WHERE yourcolumn LIKE '%''%';
    • Proposed as answer by AccDba111 Friday, February 1, 2013 8:25 PM
    Friday, February 1, 2013 7:20 PM
  • SELECT *

    FROM <Your Table > where <Fields> LIKE '%Your Desired O/P%' 

    Friday, February 1, 2013 8:19 PM