Good day. Please tell me how to correctly make a request to the database. There is a script:

my $dbqueryAllData = $db->prepare("select * ,sum(f6),sum(f7),sum(f8),sum(f9),sum(f10),sum(f11),sum(f12),sum(f13),sum(replace((f14),'+-','-')) from DPTDAT where f1 in (?,?,?,?...40000-120000штук...?,?,?,?) group by f1 order by f1"); $dbqueryAllData->execute(@rowPRODGRPs); 

How to make a request correctly, so as not to write a huge number of characters "?" Make queries in a cycle of several pieces? Or is there a way to fit all in one request?

Thanks to the comments @Mike The solution was found, where the meringue request is usual.

 select * ,sum(f3),sum(f3),sum(f4),sum(f5),sum(f6),sum(f7),sum(f8),sum(replace((f9),'+-','-')) from PLSDAT group by f1 order by f1; 
  • First you need to understand for the sake of what it is doing and what is behind these signs ? how many records in the table are and how many of them are processed by the program at a time - Mike
  • Under the signs? numbers in the format of 46070517965460645 are hidden. There are about 60000 records in the table. I want to process everything in 1 request at once. - Evgeniy A
  • And where does the program initially take them from? Not from the database? There are no regularities in the numbers, they are not in a row, they cannot be set by a range? You wrote that you have 40k characters? Do you process 2/3 of the entire table at once? If so, it can get all 60k per customer and choose which ones you need (the main thing, of course, is not to abuse, choose, say, 60k for the sake of processing 1k already somehow stressful) - Mike
  • The program initially takes them from the database. There are no regularities in the numbers, and the range cannot be set. There is a probability that among the numbers at a certain point in time there may appear values ​​with Latin letters. The number of question marks may be different, it may change (in a big way, but the range is approximately from 40k to 120k), I just would like to know the principle from which it will be possible to repel. You need to get all the tk you need to process the entire table at once. - Evgeniy A
  • one
    If you need to process the entire table - do not specify the where clause and none at all ? accordingly, the query will return everything grouped and sorted. And if these numbers were originally taken from the same database, then it is worth thinking about combining the query that originally received them with this, into one single SQL query - Mike

1 answer 1

I was faced with a situation when there are too many "?" in operator in caused drops. This was due to the features of the database driver. So advice 1: use join through join. If that doesn't work, then tip 2: write the values ​​directly in sql.