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


    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?
    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 Threads - query Records containing Date
Embarrassingly Simple SQL Server query: List Even numbers in... May 2, 2017
Basic SQL queries Jan 20, 2016
Including Nulls in Query. Dec 21, 2015
Fortran functions query Oct 28, 2015
Fortran 77: Recording the output May 17, 2015