You need something to limit the join. In theory a join with no limit will generate the cartesian product (all possible permutations of all the rows) of all joined tables. I've tried to demonstrate this below.
In general the use of DISTINCT is slow and should be avoided if possible. Hope this helps, Bret mysql> create table table1 (pk int primary key); Query OK, 0 rows affected (0.00 sec) mysql> create table table2 (pk int primary key, fk int references table1(pk)); Query OK, 0 rows affected (0.00 sec) mysql> insert into table1 values (1); Query OK, 1 row affected (0.06 sec) mysql> insert into table1 values (2); Query OK, 1 row affected (0.00 sec) mysql> insert into table2 values (1, 1); Query OK, 1 row affected (0.01 sec) mysql> insert into table2 values (2, 1); Query OK, 1 row affected (0.00 sec) mysql> insert into table2 values (3, 2); Query OK, 1 row affected (0.00 sec) mysql> insert into table2 values (4, 2); Query OK, 1 row affected (0.00 sec) mysql> select * from table1, table2; +----+----+------+ | pk | pk | fk | +----+----+------+ | 1 | 1 | 1 | | 2 | 1 | 1 | | 1 | 2 | 1 | | 2 | 2 | 1 | | 1 | 3 | 2 | | 2 | 3 | 2 | | 1 | 4 | 2 | | 2 | 4 | 2 | +----+----+------+ 8 rows in set (0.46 sec) mysql> select * from table1, table2 where table1.pk = table2.fk; +----+----+------+ | pk | pk | fk | +----+----+------+ | 1 | 1 | 1 | | 1 | 2 | 1 | | 2 | 3 | 2 | | 2 | 4 | 2 | +----+----+------+ 4 rows in set (0.00 sec) -----Original Message----- From: Rick Emery [mailto:[EMAIL PROTECTED]] Sent: Monday, January 14, 2002 3:48 PM To: 'Davis Zanetti Cabral'; [EMAIL PROTECTED] Subject: RE: Problems with search Perhaps, add the DISTINCT modifier: SELECT distinct * FROM tutoriais,scripts WHERE tutoriais.nome LIKE '%mysql%' OR tutoriais.descricao LIKE '%mysql%' AND scripts.nome LIKE '%mysql' -----Original Message----- From: Davis Zanetti Cabral [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 31, 2001 2:39 PM To: [EMAIL PROTECTED] Subject: Problems with search I have problems with searches where I try search in 2 or more tables with a query only. But the data came more that one time. I dont speak english very well... if somebody understand portuguese, please reply for me... sql => SELECT * FROM tutoriais,scripts WHERE tutoriais.nome LIKE '%mysql%' OR tutoriais.descricao LIKE '%mysql%' AND scripts.nome LIKE '%mysql' whats prob here? tanks... O meu problema eh pesquisas em 2 tabelas ao mesmo tempo... os dados se repetem... SELECT * FROM tutoriais,scripts WHERE tutoriais.nome LIKE '%mysql%' OR tutoriais.descricao LIKE '%mysql%' AND scripts.nome LIKE '%mysql' qual o problema nisso? obrigado Davis [EMAIL PROTECTED] --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php