1

In database it shows:

-Table 1 data show discount_category_id as: 1 2 3
-Table 2 data show category_id as: ,1, ,2, ,3,

So is anything wrong or any syntax error with my code because i tried print_r but no value.

->join('LEFT', $db->quoteName('#__hikashop_discount', 'e'). ' ON (' . 
 $db->quoteName('e.discount_category_id') . ' LIKE "%' . $db-
 >quoteName('d.category_id') . '%")') 
3
  • To construct a good, clear question please provide a small SQL dump of your database tables and check your error logs. If there are any errors, you are meant to tell us -- not the other way around. See what your generated query actually looks like. Please always endeavor to progress your questions toward some type of resolution.
    – mickmackusa
    May 16, 2018 at 4:47
  • Please improve this question so that future researchers will benefit from reading this page. Currently your table structures and rows are a bit unclear and your intended logic isn't clear either. We all must take care of the content that we post here as a matter of good StackExchange citizenship.
    – mickmackusa
    Jul 23, 2018 at 2:48
  • Using LIKE to match values in a comma-separated string is super bad idea. LIKE is whole-number-ignorant, so if you search for 1 you will get a match if 11, 8741, or 180 (etc.) is in the csv list. Let us help you -- edit your question please.
    – mickmackusa
    Mar 2, 2019 at 4:03

1 Answer 1

0

You’re quoting your like string with “ and then quoting the int column inside with quoteName. I’m not sure it’d work even after you fix that because int columns don’t act like strings that you just concat with %. There’s a nice discussion about using int column likes here that should help. https://stackoverflow.com/questions/8422455/performing-a-like-comparison-on-an-int-field

Not the answer you're looking for? Browse other questions tagged or ask your own question.