V
V
vhsporno2019-06-08 15:42:42
PostgreSQL
vhsporno, 2019-06-08 15:42:42

How to output duplicates with a specific pk in postgre?

5cfbac8e6ad33114627584.jpeg
There is a table. It is necessary to transfer volumio_id from the Django web muzzle. For example, volumio_id=[6,7, 2] and it shows me the general entries for these IDs. In this case it would be name="11_You_Wish.mp3". Search by name.
I need help in building a request so that I can send IDs there, and in response I get common songs. Or how to do it through ORM Djano

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vhsporno, 2019-06-09
@vhsporno

SELECT 1 as id, volo_files.name, string_agg(CAST(volo_files.volumio_id AS TEXT), ', ') AS volumio_ids, count(volo_files.name) as cnt
from volo_files
where volumio_id in %s
GROUP BY volo_files.name
HAVING count(volo_files.name) > 1

I made this request

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question