Jump to content

Edit History

ThibaultWUN

ThibaultWUN

44 minutes ago, EvaF said:

I don't argue - because i don't know your data - I only say that

the construction:
 


...WHERE id_group LIKE (SELECT id_group FROM `'._DB_PREFIX_.'group_lang` WHERE name LIKE '%MYGROUP%' AND id_lang=5)

is very unusual and leads to mysql-error if result of subquery returns more than 1 row - that's all

That's a reason  I have suggested:


...WHERE id_group IN (SELECT id_group FROM `'._DB_PREFIX_.'group_lang` WHERE name LIKE '%MYGROUP%' AND id_lang=5)

 

And you are right, it looks cleaner that way. But it still does not work. What's weird is that I tried this query in phpMyAdmin and it works...

SELECT id_customer FROM ps_customer_group WHERE id_group IN (SELECT id_group FROM ps_group_lang WHERE name LIKE 'mygroup' AND id_lang=5)

And I tried to make two queries instead of one but it does not work either.

$idGroup = Db::getInstance()->executeS('SELECT id_group FROM `'._DB_PREFIX_.'group_lang` WHERE name LIKE 'mygroup' AND id_lang=5');

It also makes my website crash... And again, it works in phpMyAdmin !

ThibaultWUN

ThibaultWUN

19 minutes ago, EvaF said:

I don't argue - because i don't know your data - I only say that

the construction:
 


...WHERE id_group LIKE (SELECT id_group FROM `'._DB_PREFIX_.'group_lang` WHERE name LIKE '%MYGROUP%' AND id_lang=5)

is very unusual and leads to mysql-error if result of subquery returns more than 1 row - that's all

That's a reason  I have suggested:


...WHERE id_group IN (SELECT id_group FROM `'._DB_PREFIX_.'group_lang` WHERE name LIKE '%MYGROUP%' AND id_lang=5)

 

And you are right, it looks cleaner that way. But it still does not work. What's weird is that I tried this query in phpMyAdmin and it works...

SELECT id_customer FROM ps_customer_group WHERE id_group IN (SELECT id_group FROM ps_group_lang WHERE name LIKE 'mygroup' AND id_lang=5)

×
×
  • Create New...