Re: SQL Select Unique() ?
| From: | CC Zona | Date: | Fri, 20 Apr 2001 02:18:52 +0000 |
| Subject: | Re: SQL Select Unique() ? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-49479@lists.php.net to get a copy of this message | ||
In article <9bng4u$ftc$1@toye.p.sourceforge.net>,
liljim@btconnect.com ("James, Yz") wrote:
> $sql = "SELECT * FROM table WHERE category LIKE 'Public House / Restaurant'
> OR description LIKE 'Public House / Restaurant'";
>
> Surely that would bring the same row back twice....
Surely not. Have you tried it yet? Unless there are duplicate rows in the
table (which should *not* be the case), each row that is matched by that
query should only be returned once per execution of the query.
> Is there any way of
> selecting from the table just once, without having to restrict the search
> facility to something like:
>
> "SELECT * FROM table WHERE category LIKE '%$searchtext%'";
>
> as opposed to having the "OR" in as well?
I'm not sure what you're after. If executing the top example is getting
you unwanted rows, perhaps you could re-post with some sample data and
pointing out which rows are being shown in duplicate. (It might also be a
good idea to re-check your data first if there's any possibility that there
are duplicate rows existing in the db. 'Cuz that's the kind of thing
that's gonna mis-lead you about how SQL queries normally work.)
--
CC