problem with mysql query

Discussion in 'Databases' started by ronaldv, Sep 26, 2009.

  1. #1
    I'm running the following query to retrieve a specific country from a list of countries:

    $r=" SELECT * FROM " . DB_PREFIX . "fields_items AS fi LEFT JOIN " . DB_PREFIX . "fields AS f ON ( f.field_id = fi.field_id ) WHERE f.label = 'country' ".$qq;

    I'm having a problem with countries with special characters like "España". The query tries to find "Espana" (that's the input or value of the parameter), and returns no results, because the DB only has "España" values. The input "Espana" is correct, I need to keep it, but how could I convert it just for this query? or how to make the query return all "España" values??

    Maybe this is a simple problem, but I'm just a novice ;)
     
    ronaldv, Sep 26, 2009 IP
  2. ThomasTwen

    ThomasTwen Peon

    Messages:
    113
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    "España" and "Espana" are two different strings - which is why your query does not work.

    $r=" SELECT * FROM " . DB_PREFIX . "fields_items AS fi LEFT JOIN " . DB_PREFIX . "fields AS f ON ( f.field_id = fi.field_id ) WHERE f.label LIKE 'country' ".$qq;
    Code (markup):
    Use "like" as in the query above, and query for "Espa*a" instead of "Espana". Note that this will match all strings starting with "Espa" and ending with "a"
     
    ThomasTwen, Sep 27, 2009 IP