Maximum length of mySQL request ?

Paul Dupuis paul at researchware.com
Fri May 20 08:00:37 EDT 2022


You can save some characters by the following:

SELECT ... FROM myTable WHERE id IN (5523,7831,162814,34895,...)

which is the same as using multiple OR equals in your example.

If you need to break this up further, you can UNION the results of 
multiple queries, such as:

SELECT ... FROM myTable WHERE id IN (5523,7831,162814,34895,...) -- i.e. 
the first 100 or 1000 ids
UNION
SELECT ... FROM myTable WHERE id IN (100,512,9999,16545,...) -- the next 
100 or 1000 ids
UNION
... repeat as needed

On 5/20/2022 6:34 AM, jbv via use-livecode wrote:
> Hi list,
>
> Is there a maximum length limit for mySQL requests ?
> I don't mean the results returned by mySQL, but the request itself.
>
> For instance, I have a table with 180000 entries and counting, and
> I will need to send requests such as :
> SELECT FROM myTable WHERE id = 5523 OR id = 7831 OR id = 162814 OR id 
> = 34895...
> and at times the request might concern 100 ids or even more.
>
> I am not too concerned about execution speed, as id is a unique key,
> but rather for the request itself : I wonder if it might be truncated
> if too long...
> Or perhaps a better and safer practice would be to break it into a 
> serie of
> shorter successive requests when it exceeds a certain threshold ?
>
> Thank you in advance.
> jbv
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your 
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




More information about the use-livecode mailing list