sql - Small Php and MySql problem -


I have an array of id: s, and id: s is in this format:

  Bmw_330ci_89492822  

So this is a string!

Now, I have this code which is in that array, in MySQL: ( $ solr_id_arr I have the above mentioned array, it has string id: s) ex: < Code> $ solr_id_arr [0] output BMWA 303066_89492822

  $ Solr_id_arr_imploded = implode (",", $ solr_id_arr); $ Query = "SELECT * my_table from where ad_id IN ('$ solr_id_arr_imploded')"; $ Qry_result = mysql_query ($ query) or die (mysql_error ());  

The problem does not work because (I think) that to find the match of MySQL, there should be quotation around each inherent element. Fields in MySQL I'm matching Varchar

Here $ query is:

  SELECT * my_table to WHERE ad_id IN ('Bmw_m3_cool_565440282, BMV_M 5_839493889')  < / Pre> 

Do you have any other solution for this, I only need to find matches in MySQL which is in this array!

Thanks

Do not cover the entire object in quotation marks Is where ad_id 'bmw_m3_cool_565440282, test'

use

  SELECT * my_table WHERE ad_id IN ('Bmw_m3_cool_565440282', 'test ')  

A quick correction has to be done:

  // This $ solr_id_arr_imploded = implode (",", $ solr_id_arr); // for $ solr_id_arr_imploded = implode ("','", $ solr_id_arr);  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -