Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

SQL query for Records containing a Character

  1. Oct 13, 2015 #1

    WWGD

    User Avatar
    Science Advisor
    Gold Member

    Hi All,
    I am trying to do an SQL query for records containing a certain character, say, c , in 'field'

    I think if the character c is at the beginning, we use :

    Select ..... from table
    where field like 'c % ' , where % is a wildcard.

    Similar for cases where the character is at the end, i.e., we would use :

    Select ... from table
    where field like '% c '.

    But if the character c was somewhere in the middle , would we use :

    Select .... from table
    where field like '% c % ' ?

    EDIT: I assume the last choice, '% c % ' covers all cases, since % may stand for an empty string.
    Is this correct?
    Thanks.
     
    Last edited: Oct 13, 2015
  2. jcsd
  3. Oct 13, 2015 #2
    Yes, everything you have said is correct.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: SQL query for Records containing a Character
  1. I need a SQL query (Replies: 3)

  2. Need Help on SQL query (Replies: 3)

Loading...