[support] query, like and %s

Michel Morelli michel at ziobuddalabs.it
Fri Sep 4 09:58:40 UTC 2009


Hi all. I have this query:

$query = "SELECT DISTINCT sum(re.field_rows_ext_quantity) as q, re.nid, 
n.title from content_field_rows_ext re JOIN node n on re.nid = n.nid 
where lower(field_rows_ext_brand) like '%%s% group by n.title"

and this code
$res = db_query($query,$marca);

But when i show the output of this query the result for q is wrong. Is 
correct if I exec this code:

$query = "SELECT DISTINCT sum(re.field_rows_ext_quantity) as q, re.nid, 
n.title from content_field_rows_ext re JOIN node n on re.nid = n.nid 
where lower(field_rows_ext_brand) like '%$marca% group by n.title"
$res = db_query($query);

Where is my error ?

M.

-- 
Michel 'ZioBudda' Morelli                       michel at ziobuddalabs.net
Sviluppo applicazioni CMS DRUPAL e web dinamiche (LAMP+Ajax)
Telefono: 0200619074
Telefono Cell: +39-3939890025 --  Fax: +39-0291390660

http://www.ziobudda.net                         ICQ: 58351764  
http://www.ziobuddalabs.it                      Skype: zio_budda
http://www.ziodrupal.net       			MSN: michel at ziobuddalabs.it                   
						JABBER: michel at ziobuddalabs.it



More information about the support mailing list