Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [mysql] WHERE nie ma takiej kolumny
propage
post
Post #1





Grupa: Zarejestrowani
Postów: 330
Pomógł: 0
Dołączył: 25.01.2008

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


Mamy zapytanie powiedzmy:

  1. <?php
  2. Select *, p.price as real_price FROM product p WHERE real_price > '500'
  3. ?>


MySQL twierdzi mi, że nie ma takiej kolumny "real_price" i wywala błąd.

Jednak można po niej sortować
  1. <?php
  2. Select *, p.price as real_price FROM product p ORDER by real_price DESC
  3. ?>


I tutaj mysql nie robi żadnych problemów, może ktoś mi to wytłumaczyć?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
propage
post
Post #2





Grupa: Zarejestrowani
Postów: 330
Pomógł: 0
Dołączył: 25.01.2008

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


Hm jednak te zapytanie, nie działa u mnie prawidłowo tz, zawsze zwraca mi takie same wartości prev i next dla każdego elementu, nie zależnie jakie sortowanie ustawie i metode.

I zamodyfikowane zapytanie o prev i next

  1. <?php
  2. SELECT DISTINCT p.product_id as product_id, p.product_name, p.vat_id, if (pro.promotion_status, pro.promotion_price, p.product_price) as real_price, p.product_onStock, p.product_content, p.product_image, pro.promotion_price, p.product_price, pro.promotion_status, p.product_url, p.product_content, p.product_show, @nr:=@nr+1, if( p.product_id <>@id and not @idprevfound, @idprev := p.product_id, if(@idprevfound,null,@idprevfound:=1) ), if( p.product_id = @id, @idnextfound := 1, if(@idnextfound and not @idnext, @idnext := p.product_id, null) ) FROM product p left join product_2_category p_2_c on (p_2_c.product_id = p.product_id) left join category c on (c.category_id = p_2_c.category_id) left join promotion pro on (pro.product_id = p.product_id ) WHERE p.product_show = 1 AND c.category_id IN (3, 3) order by p.product_name DESC
  3. ?>


co bym nie wstawił w order by zawsze dostane takie same wartości next i prev. Gdzie jest błąd ?
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: 14.10.2025 - 03:32