Re: searching trought multiple tables
| From: | Richard Lynch | Date: | Sat, 22 Sep 2001 02:05:31 +0000 |
| Subject: | Re: searching trought multiple tables | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-68252@lists.php.net to get a copy of this message | ||
Either you are missing a constraint (one of the *AND* bits in a WHERE
clause) or you actually have duplicates in the join. Can't tell which
without knowing more about the schema.
You could just use "select DISTINCT ..." and let MySQL get rid of the
duplicates. That may be kinda slow on 5,000 rows though, depending on your
hardware/RAM and the phase of the moon.
--
WARNING richard@zend.com address is an endangered species -- Use
ceo@l-i-e.com
Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm
----- Original Message -----
From: Daniel Masur <d.masur@d-s-a-g.de>
Newsgroups: php.general
To: <php-general@lists.php.net>
Sent: Monday, September 17, 2001 9:21 AM
Subject: searching trought multiple tables
> i have a mysql database with 100 entrys in 3 tables.
>
> i need to search trought them, but if i search for 'a' in all tables, i
get
> 5000 results...
>
> 70 results are the same.
>
> heres my code:
> $sql_find="
> SELECT
> mieter.miet_name, mieter.cat_id, mieter.id,
> mieter.miet_beschreibung, cat.cat_name, events.name
> FROM
> mieter AS mieter,
> categories AS cat,
> events AS events
> WHERE
> mieter.miet_name LIKE '%$words%'";
> if($option1) $sql_find = $sql_find . " AND mieter.cat_id =
'$option1'";
> $sql_find = $sql_find . " OR mieter.miet_beschreibung LIKE
'%$words%'";
> $sql_find = $sql_find . " or events.name LIKE '%$words%'";
>
> with $option1 enabled you can search trought subcategories. can anybody
help
> me?
>
>