Re: Logicproblem in WHERE statement

From: Date: Wed, 16 Jan 2002 22:24:37 +0000
Subject: Re: Logicproblem in WHERE statement
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-15898@lists.php.net to get a copy of this message
Andy > == relevance ?? > > ... or define a calculated field for these "relevance"... and order the > results by this value... > > SELECT (sex = 1 AND country = 'CA') AS relevance, sex, country > FROM table > WHERE sex = 1 > ORDER BY 1 DESC > > ... note the relevance includes all the fields... and the where just the > mandatory conditions... the order must be DESC, because the "relevance" is 1 > if the two conditions are match... and 0 if not you can define a more sophisticated relevance function... for example, if you want to search three different terms... example terms... sex = 1 age = 30 country = 'CA' [in MySQL]... you can define relevace as... (sex = 1) + (age = 30) + (country = 'CA') relevance will be... 3 if the three conditions are match 2 if just two conditions are match 1 if just one condition is match 0 if non is match if you are trying to define an "any word" query... you can show just the rows (where relevance > 0)... if you are trying to define an "all words" query... you can show the rows where relevance == 3... or re-define the query and include all the columns in the where clause !! 8-) jaime

« previous php.db (#15898) next »