Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> 3 zapytania do 1 tabeli - scalenie do 1 zapytania
Ryder
post 30.11.2012, 19:14:10
Post #1





Grupa: Zarejestrowani
Postów: 74
Pomógł: 1
Dołączył: 5.01.2008

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


Witam

Mam takie 3 zapytania: (1 tabela)
  1. SELECT count(id) AS ok FROM comments WHERE receiver_id = '10' AND reference = 'positive',
  2. SELECT count(id) AS nok FROM comments WHERE receiver_id = '10' AND reference = 'negative',
  3. SELECT count(id) AS comments FROM comments WHERE receiver_id = '10' AND comments IS NOT NULL


Chciałbym zrobic z tego 1 zapytanie, które zwróciły 1 wiersz z 3 wartosciami ok, nok, comments.
W jaki sposób najlepiej to zrobic?

Juz nieaktualne . Znalazłem rozwiazanie

  1. SELECT count( DISTINCT IF( reference = 'positive', ID, NULL ) ) , count( DISTINCT IF( reference = 'negative', ID, NULL ) ) , count( DISTINCT IF( comments IS NOT NULL , ID, NULL ) )
  2. FROM meeting_comments WHERE receiver_id = '10'


Ten post edytował Ryder 30.11.2012, 19:08:39
Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 23.06.2025 - 13:40