Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> LEFT JOIN daje za dużo wyników
miedzna
post
Post #1





Grupa: Zarejestrowani
Postów: 401
Pomógł: 1
Dołączył: 10.03.2004
Skąd: Warszawa

Ostrzeżenie: (0%)
-----


Otóż mam 2 tabeli o identycznej strukturze, ale zawierające różne dane:

  1. CREATE TABLE tabela1 (
  2. `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  3. `name` varchar(255) NOT NULL,
  4. `kod` varbinary(30) NOT NULL,
  5. PRIMARY KEY (`id`)
  6. ) ENGINE=MyISAM DEFAULT CHARSET=latin2;
  7.  
  8. CREATE TABLE tabela2 (
  9. `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  10. `name` varchar(255) NOT NULL,
  11. `kod` varbinary(30) NOT NULL,
  12. PRIMARY KEY (`id`)
  13. ) ENGINE=MyISAM DEFAULT CHARSET=latin2;



Pierwsza tabela zawiera 2862 rekordy, a druga 2892 rekordy. Robię zapytanie:

  1. SELECT t1.name AS nameO, t1.kod AS kodO, t2.name AS nameM, t2.kod AS kodM FROM tabela1 t1 LEFT JOIN tabela2 t2 ON t1.name = t2.name;


Chcę pobrać tylko te rekordy z obu tabel, nazwy których w polu name są identyczne. Według mojej wiedzy, powinno mi pobrać około 2500 rekordów, a pobiera aż 4431, gdzie robię źle?
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 3.10.2025 - 23:46