Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Select, as, where problem, modyfikacja zapytania sql
Fixer
post
Post #1





Grupa: Zarejestrowani
Postów: 123
Pomógł: 0
Dołączył: 24.10.2004
Skąd: TG

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


Ktoś wie w jaki sposób poprawnie dodać tutaj frazę where?
mam mysql 5.1 i mam mały problem z dodaniem frazy where

  1. SELECT *, (
  2. (`lotto_duzy_lotek`.`1` IN (8,12,31,6,7,8)) +
  3. (`lotto_duzy_lotek`.`2` IN (8,12,31,6,7,8)) +
  4. (`lotto_duzy_lotek`.`3` IN (8,12,31,6,7,8)) +
  5. (`lotto_duzy_lotek`.`4` IN (8,12,31,6,7,8)) +
  6. (`lotto_duzy_lotek`.`5` IN (8,12,31,6,7,8)) +
  7. (`lotto_duzy_lotek`.`6` IN (8,12,31,6,7,8))
  8. ) AS trafnosc
  9. FROM `lotto_duzy_lotek` WHERE trafnosc = '4'
  10. WHERE `lotto_duzy_lotek`.`trafnosc` > '2'
  11. ORDER BY `trafnosc` DESC;


#1054 - Unknown column 'trafnosc' in 'where clause'
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
kefirek
post
Post #2





Grupa: Zarejestrowani
Postów: 781
Pomógł: 256
Dołączył: 29.06.2008

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


Cytat
@kefirek to jest pole a nie tabela.
sek w tym ze do aliasow z select nie mozna sie dobierac w where

edit: no i usunal sie kefirek.... dziwnie wyglada moj post


Bo sie pomyliłem i usunełem post (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif)

Powinno byc chyba tak

powinno dzialac


  1. SELECT * FROM ( SELECT *,
  2. (`lotto_duzy_lotek`.`1` IN (8,12,31,6,7,8)) +
  3. (`lotto_duzy_lotek`.`2` IN (8,12,31,6,7,8)) +
  4. (`lotto_duzy_lotek`.`3` IN (8,12,31,6,7,8)) +
  5. (`lotto_duzy_lotek`.`4` IN (8,12,31,6,7,8)) +
  6. (`lotto_duzy_lotek`.`5` IN (8,12,31,6,7,8)) +
  7. (`lotto_duzy_lotek`.`6` IN (8,12,31,6,7,8))
  8. AS trafnosc FROM `lotto_duzy_lotek`
  9. ) AS tabela
  10. WHERE trafnosc = '4' AND `trafnosc` > '2'
  11. ORDER BY `trafnosc` DESC;


Ten post edytował kefirek 7.03.2009, 21:20:04
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: 15.10.2025 - 01:52