Re: OR on multiple columns

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thursday 09 January 2003 08:36, David Chamberlin wrote:
> I was reading the mysql docs and noticed a section on searching on
> multiple keys (stupid question - keys=columns?).  It says doing an OR on
> multiple keys is inefficient, and you should use a temp table.  Here's
> their example:
>
> CREATE TEMPORARY TABLE tmp
> SELECT field1_index, field2_index FROM test_table WHERE field1_index = '1';
> INSERT INTO tmp
> SELECT field1_index, field2_index FROM test_table WHERE field2_index = '1';
> SELECT * from tmp;
> DROP TABLE tmp;
>
> My question is, is there a point at which this temp table is less
> efficient?  

That may depend upon your particular circumstances, and hence running your own 
tests on both methods would give you the best answer.

> Also, as a minor side-note - every time I tried to do the createTmpTable
> function by creating one big sql string, separating commands with a ';',
> I got a syntax error.  Is it not legal to do this? 

The php-mysql interface does not support multiple queries.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *


/*
A handful of friends is worth more than a wagon of gold.
*/


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux