Re: help with sql statement
| From: | Richard Quadling | Date: | Tue, 13 Jul 2010 09:13:59 +0000 |
| Subject: | Re: help with sql statement | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-306861@lists.php.net to get a copy of this message | ||
On 12 July 2010 18:34, Tommy Pham <tommyhp2@gmail.com> wrote:
> SELECT srs.Name FROM SMS_R_System srs WHERE srs.SystemOUName IN
> ("example.com/COMPUTERS/MAIN CAMPUS/ABC", "example.com/COMPUTERS/MAIN
> CAMPUS/XYZ")
>
As this is a single table query, there is no need for the table alias.
SELECT Name FROM SMS_R_System WHERE LEFT(SystemOUName, 34) =
'example.com/COMPUTERS/MAIN CAMPUS/' AND RIGHT(SystemOUName, 3) IN
('ABC', 'XYZ')
But this will probably take a measurable amount of time longer to
execute - 2 comparisons and 2 string processes. Maybe not for a single
run, but after several hundred.