-1

I have table with this structure id, brand, email, url and I want to make this kind of query but I cant find how to put IN condition.

SELECT email FROM `table_name` WHERE brand IN ('VW', 'Volvo');

Can you help me please?

closed as too broad by kiamlaluno Jun 9 at 10:51

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

3

Direct from the docks

https://www.drupal.org/docs/8/api/database-api/dynamic-queries/conditions

$users = [2,5,17,22];

$query->condition('uid', $users, 'IN');

so in your case:

$brands = [
  'Toyota',
  'Volvo',
 ...
];
$connection = \Drupal::database();
$query = $connection->query("SELECT email, example FROM {tablename}");
$query->condition('brand', $brands, 'IN');
$result = $query->fetchAll();

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