Answer the question
In order to leave comments, you need to log in
How to make a SQL query on a list of id, instead of the whole table?
Hello!
Can you please tell me how to edit the query so that the calculation is not for the entire table, but for the id list?
Filtering the results is not suitable, because the query takes too long, the database is large enough, there are a lot of records.
The request itself:
SELECT my_table.id AS id, sum(child.qty) AS all_child_qty
FROM my_table
LEFT OUTER JOIN my_table as child
ON child.my_path LIKE (my_table.my_path || '%')
GROUP BY my_table.id
);
Answer the question
In order to leave comments, you need to log in
...
WHERE my_table.`id` IN (<ids_coma_separated_list>)
GROUP BY ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question