I have a vb.net application running a process. In order to speed it up I have split it into several threads, the process asks for employees in groups of names as below.
SELECT * FROM Employ WHERE Name like '[A-C]%' ORDER BY RDate DESC
Mostly I have groups like 'A-C' and so on, but it just so happens that the 'Ms' are the biggest group, so I made them their own group, 'M-M' and even that is not enough, their thread takes way too long to finish. So I would like to make 2 groups like this 'Ma-Mm' and 'Mn-Mz'.
Is it just a case of changing the above query to those letters? like:
SELECT * FROM Employ WHERE Name like '[Ma-Mm]%' ORDER BY RDate DESC
SELECT * FROM Employ WHERE Name like '[Mn-Mz]%' ORDER BY RDate DESC
Also providing that that name column is indexed, is this the most optimal way to write that query?
Edit: I am using Ms SQL Server
If you are using SQL Server, you can do:
WHERE Name like 'M[a-m]%'
However, a generate range, such as My-No, would be harder to express. You can always do:
WHERE name >= 'Ma' and name < 'Mn'
as well. This works for more complex ranges.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With