0

I am using PostgreSQL 11.5 on Ubuntu

Question

How can I get data/rows for more selected ids in one where condition? Ideally from file with list of ids.

Example

|product_id |product_name                                                                                        |product_url                                                                                         |filename                                                                                            |
|-----------|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|
|134810     |Vliesová tapeta bílostříbrný květ                                                                   |bydleni-tapety-vliesove-tapety-vliesova-tapeta-bilostribrny-kvet                                    |331322.jpg                                                                                          |
|134827     |Vliesová tapeta Grandeco Exposed PE-11-01-1                                                         |bydleni-tapety-vliesove-tapety-vliesova-tapeta-grandeco-exposed-pe-11-01-1                          |331325.jpg                                                                                          |
|134827     |Vliesová tapeta Grandeco Exposed PE-11-01-1                                                         |bydleni-tapety-vliesove-tapety-vliesova-tapeta-grandeco-exposed-pe-11-01-1                          |331325i.jpg                                                                                         |
|134807     |Vliesová tapeta béžová se stříbrnými pírky                                                          |bydleni-tapety-vliesove-tapety-vliesova-tapeta-bezova-se-stribrnymi-pirky                           |336628.jpg                                                                                          |
|134948     |Prskavky 90 cm 3 ks                                                                                 |zahrada-vanoce-vanocni-dekorace-prskavky-90-cm-3-ks                                                 |sp16-2.jpg                                                                                          |
|134943     |Krmítková směs 400 g                                                                                |zahrada-zimni-sortiment-krmitka-pro-ptactvo-krmivo-pro-ptactvo-krmitkova-smes-400-g                 |427298-krm-tov-sm-s-400g.jpg                                                                        |
|135074     |Sluban B0519 Fontánový kruháč se skútrem                                                            |zahrada-pro-deti-stavebnice-sluban-b0519-fontanovy-kruhac-se-skutrem                                |m38-b0519-1.jpg                                                                                     |
|145556     |Skříň LOGICO HIGH 65 x 45 x 182 cm                                                                  |bydleni-ulozne-boxy-a-kosiky-ulozne-skrine-skrin-logico-high-65x45x182-cm                           |343453-9634000-logico-high-cabinet-0270-preview.jpg                                                 |
|145556     |Skříň LOGICO HIGH 65 x 45 x 182 cm                                                                  |bydleni-ulozne-boxy-a-kosiky-ulozne-skrine-skrin-logico-high-65x45x182-cm                           |343453-9634000-logico-high-front-preview.jpg                                                        |
|135088     |Krbová kamna Verso                                                                                  |stavba-kamna-a-krby-krbova-kamna-a-biokrby-krbova-kamna-krbova-kamna-verso                          |verso-1.orez2.jpg

... and many more.

I need get data only for some ids/rows. Is there a way to insert file into where condition? Or must I use where ... and where ... and where condition for every id I need?

2
  • 1
    Be more specific. What is your conditions? Why something simple similar to WHERE id IN (134827, 135074, 135088) is not safe for you?
    – Akina
    Commented Aug 14, 2019 at 10:34
  • Because I generate list of selected ids to file via bash script before, so it would be perfect when I use this file into wherecondition.
    – genderbee
    Commented Aug 14, 2019 at 10:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.