Re: OR on multiple columns

From: Date: Thu, 09 Jan 2003 04:02:01 +0000
Subject: Re: OR on multiple columns
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-24682@lists.php.net to get a copy of this message
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. */

« previous php.db (#24682) next »