SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2003
    Location
    Toronto, ON, Canada
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Query problem with commas in field

    I am using a statement like the following:

    select * from table where Customer LIKE '%Some Company%'

    It works just fin in SQL Query Analyzer but through ADO web connection it will not return a row where the Customer field is:

    Some Company, Another Company, Acme, ABC Corp

    It seems to be the commas that are causing the problem - any way to resolve this?

    Thanks

    Rob.

  2. #2
    SitePoint Guru asterix's Avatar
    Join Date
    Jun 2003
    Posts
    847
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    what makes you think the commas are the problem?
    Your query (is probably slow) seems fine.

  3. #3
    SitePoint Addict danfran's Avatar
    Join Date
    Jan 2005
    Location
    New York City
    Posts
    244
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Torgos,

    I'm not discounting the fact that something strange might be going on here, but I must first suggest that you output the SQL statement that you are passing to SQL Server directly on the webpage from which it is being executed. Specifically, put an unusual character around the statement so that you can see whether or not there is a SPACE character before the last percent sign.

    It could simply be a matter of not trimming the var that holds "Some Company".

    This will return zero records:
    select * from table where Customer LIKE '%Some Company %'

    let us know!

    -Dan

  4. #4
    SitePoint Guru asterix's Avatar
    Join Date
    Jun 2003
    Posts
    847
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dan, that is excellent advice.

  5. #5
    SitePoint Enthusiast
    Join Date
    Jun 2003
    Location
    Toronto, ON, Canada
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And also extremely accurate - that was indeed the problem.

    Thank you very much to all for the advice.

    Rob.


Bookmarks

Posting Permissions

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