MySQL and %

Discussion in 'Programming/Scripts' started by edge, Oct 31, 2010.

  1. edge

    edge Active Member Moderator

    Anyone here who can tel me what I'm doing wrong here with the query.

    The folowing query works
    PHP:
    $rubID "16602270";
    $query_rsFilesRSS "select productID FROM rssImport WHERE productID LIKE $rubID";
    For some reason the query below gives me a "Query was empty" error.
    PHP:
    $rubID "%16602270%";
    $query_rsFilesRSS "select productID FROM rssImport WHERE productID LIKE $rubID";
    I get the same "Query was empty" error when I use the following query
    PHP:
    $rubID "16602270";
    $query_rsFilesRSS "select productID FROM rssImport WHERE productID LIKE %$rubID%";
    Again. The 1st query works fine, but will only show an exact match on $rubID.
    I want to use the % for wildcard searches.
     
  2. falko

    falko Super Moderator Howtoforge Staff

    Try
    PHP:
    $rubID "16602270";
    $query_rsFilesRSS "select productID FROM rssImport WHERE productID LIKE '%".$rubID."%'";
     

Share This Page