Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Zapytanie z wielkokrotnym left join
lustfingers
post 5.01.2016, 16:51:58
Post #1





Grupa: Zarejestrowani
Postów: 99
Pomógł: 5
Dołączył: 18.03.2015

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


Witam, uczę sie pilnie php i mysql jednak czasami coś mnie przystawi, próbuje z bazy pobrać pewne dane moje zapytanie wygląda tak:

  1. SELECT ps_order_detail.id_order, ps_orders.id_customer, ps_customer.firstname, ps_customer.lastname, ps_customer.email, ps_address.address1, ps_address.address2, ps_address.postcode, ps_address.city, ps_address.phone_mobile
  2. FROM ps_order_detail
  3. WHERE product_id = '18' OR product_id = '19' OR product_id = '20' OR product_id = '21' OR product_id = '45'
  4. LEFT JOIN ps_orders
  5. ON ps_orders.id_order = ps_order_detail.id_order
  6. LEFT JOIN ps_customer
  7. ON ps_customer.id_customer = ps_orders.id_customer
  8. LEFT JOIN ps_address
  9. ON ps_customer.id_customer = ps_address.id_customer
  10. GROUP BY ps_address.id_customer


Otrzymuję komunikat:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LEFT JOIN ps_orders
ON ps_orders.id_order = ps_order_detail.id_order
LEFT JOIN ' at line 4

Ktoś mnie może nakierować co robię źle?
Go to the top of the page
+Quote Post
Pyton_000
post 5.01.2016, 16:52:37
Post #2





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


WHERE daj PRZED GROUP BY
Go to the top of the page
+Quote Post
lustfingers
post 5.01.2016, 16:57:40
Post #3





Grupa: Zarejestrowani
Postów: 99
Pomógł: 5
Dołączył: 18.03.2015

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


Ślicznie dziękuję, zapamiętam na przyszłość smile.gif
Go to the top of the page
+Quote Post
Pyton_000
post 5.01.2016, 16:58:49
Post #4





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


Tak ściślej biorąc to WHERE powinno być PO JOIN-ach
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: 13.08.2025 - 22:31