By tpainton on
I have a table with several columns, I am trying to retrieve nid where a certain value is in found in the serialized data of column data.
So far, without luck I am trying.
<?php
$prod_nid = db_query("SELECT nid FROM {uc_cart_products} WHERE data LIKE %d", 44);
print db_result($prod_nid);
?>
44 is located in the data serialized data array.. This returns nothing. All help greatly apprecited!
Comments
Ahh found it in another
Ahh found it in another module.. whew
The where clause, data LIKE
The where clause,
data LIKE %dshould look likedata LIKE '%%%d%%', you need the quotes because the stored value is a string. The '%%' after passing through db_query becomes a '%', the final query passed to mysql will haveWHERE data LIKE '%44%'for the where clause.