[thelist] MySQL "OR"
Paul Waring
paul at xk7.net
Thu Sep 8 08:15:12 CDT 2005
On Thu, Sep 08, 2005 at 07:50:48AM -0500, Andrew Kamm wrote:
> Is it proper to execute a rather long SQL query in MySQL? I'm not aware of
> a reason this wouldn't work (unless there is simply a limit on the length of
> a queries), but I'm not sure if it's bad form or if the DB would respond
> poorly.
As far as I know, there isn't a limit, but it might take a while for
MySQL to parse extremely long query strings.
> //Create 'or' section of query with array
> $q_or = implode(" OR advertiser_id = ", $newAdvertisers);
Try:
$q_or = " WHERE advertiser_id IN ( " . implode(",", $newAdvertisers) . "
)";
The IN comparison operator works like a bunch of ORs in this case
(though there is another use of it). See this page for more information:
http://www.1keydata.com/sql/sqlin.html
I believe phpBB also uses this sort of query in some of its code
(groupmod.php or something) if you want to see a real world example.
Hope this helps!
Paul
--
Rogue Tory
http://www.roguetory.org.uk
More information about the thelist
mailing list