Results 1 to 9 of 9

Thread: SQL Search for ' (*RESOLVED*)

  1. #1

    Thread Starter
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176

    Resolved SQL Search for ' (*RESOLVED*)

    I think this is the right forum for it

    Its an SQL question

    how do I do a search for a string containing the ' char eg

    50's 60's etc. Whenever I try I get an operator error because ' is a used element in SQL. You must be able to search for it though cant you

    E.g

    SELECT * FROM [AllTable] WHERE [AllIdeas] LIKE *'50's'*

    I tried

    SELECT * FROM [AllTable] WHERE [AllIdeas] LIKE *'[50's]'*


    Anyone know this one?
    Last edited by BodwadUK; Nov 11th, 2004 at 04:35 AM.
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    Use replace function on the users input and wildcards...
    And you'd need to move the single quotes to enclose the asterisks
    Code:
    SELECT * FROM [AllTable] WHERE [AllIdeas] LIKE '*50?s*'

    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3
    Fanatic Member
    Join Date
    Sep 2004
    Location
    Jakarta, Indonesia
    Posts
    818
    make a double single quote for every single quote?

    1st NF - a table should not contain repeating groups.
    2nd NF - any fields that do not depend fully on the primary key should be moved to another table.
    3rd NF - there should be no dependency between non key fields in same table.
    - E. Petroutsos -


    eRiCk

    A collection of "Laku-abis" Ebook, Permanent Residence

    Access Reserved Words, a Classic Form Bug, Access Limitation, Know run Process and the Lock they hold in, Logging User Activity in MSSQL,
    Kill Database Processes

  4. #4

    Thread Starter
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    Silly question does ? mean any char?
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  5. #5
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036
    Hi Bod

    If your are using m$ sql server this is your should to the query


    SELECT * FROM TableName WHERE TableField like ' %' + char(39) + '%'

    Regards
    Jorge
    "The dark side clouds everything. Impossible to see the future is."

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    The question mark (?) is a wildcard. It looks for any one character in place of the ?

    So searching for

    50?s

    would return anything containing


    50Ms
    50's
    50#s

    and so on.

    But it would NOT return

    50####s

  7. #7

    Thread Starter
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    yay I put * in instead of ' and it works

    Didnt realise what you meant by wild card until my brain kicked in

    Thanks you two
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  8. #8
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Thanking me too, Boddy Woddy? :flirt:

  9. #9

    Thread Starter
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    Thanks everyone who posted in this thread if I could snog you I would
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width