Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2008
    Posts
    36

    Unanswered: this SELECT query didn't work

    This SELECT query didn't work.
    Code:
    SELECT * FROM xcart_product_options_js
       WHERE javascript_code LIKE 'pull-down menu just above the "Take it" button'
       LIMIT 0 , 100
    No records were found, even though I know those values exist. Do I need to escape the quote characters or something like that? Thank you

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    you didn't use any LIKE wildcard characters, so the query is looking for a row with an exact match for that column value
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Apr 2008
    Posts
    36
    Code:
    SELECT * FROM xcart_product_options_js
       WHERE javascript_code LIKE '%pull-down menu just above the "Take it" button%'
       LIMIT 0 , 100
    Ok, then is this correct? But it still does not find the records...

  4. #4
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    You do not need to escape the double quotes so it does look alright. If this does not work then I would look more closely at my data in the database.
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

  5. #5
    Join Date
    Apr 2008
    Posts
    36
    Quote Originally Posted by r937 View Post
    you didn't use any LIKE wildcard characters, so the query is looking for a row with an exact match for that column value
    Yes, that is probably the issue, as I am not looking for an exact match...just a match of that string within the entire column value. How do I add wildcard characters to the query, please?

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by Leafgreen View Post
    Yes How do I add wildcard characters to the query, please?
    you did this already, in post #3 -- the percent signs

    as ronan said, look at your data more closely
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  7. #7
    Join Date
    Apr 2008
    Posts
    36
    Nope. It's the query syntax. If I execute
    Code:
    SELECT *
    FROM `xcart_product_options_js`
    WHERE `javascript_code` LIKE '%pull-down menu just above the%'
    LIMIT 0 , 30
    then I get a found set. if I execute
    Code:
    SELECT *
    FROM `xcart_product_options_js`
    WHERE `javascript_code` LIKE '%pull-down menu just above the ''Take it'' button%'
    LIMIT 0 , 30
    then I get no results. The problem is the quotes in ''Take it''. I've also tried " character. BTW, if I try searching just Take it then I also do not get any results. The '' messes things up. Please help. Thank you.

  8. #8
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by Leafgreen View Post
    Please help. Thank you.
    do you know how to dump a table?

    please dump the table, then copy both the CREATE TABLE statement, as well as the INSERT statement for at least one row which contains the data that you're trying to return with this query
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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