Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem z zapytaniem, You have an error in your SQL syntax
NetJaro
post
Post #1





Grupa: Zarejestrowani
Postów: 475
Pomógł: 0
Dołączył: 1.04.2005
Skąd: Warszawa

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


Witam, mam zapytanie:

  1. <?php
  2. $query = "SELECT member_details.jointed_date, member_details.f_name, member_details.l
    ogin, member_details.mem_id, member_details.email_id, count(member referrals.mem_id) as 'dupa' FROM `member_referrals`, member_details where member_details.mem_id=member_refe
    rrals.parent_id and member_details.joined_date >= '2005-09-30' in member_details.mem_id=member_referrals.mem_id group by member_referrals.pare
    nt_id order by 'dupa' DESC limit 0,30"
    ;
  3. ?>


Jednak pojawia się błąd:

Cytat
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 'member_details.mem_id=member_referrals.mem_id group by member_referrals.parent_' at line 3


Co tutaj jest źle?

Ten post edytował NetJaro 20.12.2005, 17:48:30
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
kszychu
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 2 712
Pomógł: 23
Dołączył: 27.10.2003
Skąd: z kontowni

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


Zamiast długich nazw tabel możesz używać ich aliasów. Alias definiujesz w sposób:
FROM bardzo_dluga_nazwa_tabeli as t1
i w całym zapytaniu możesz stosować:
SELECT t1.pole1, t1.pole2
oraz w warunkach:
WHERE t1.pole1= t2.pole2 (dla jakiejś innej tabeli t2)

Aliasy możesz również stosować dla nazw pól, np:
SELECT t1.pole1 as p1, t1.pole2 as p2 Później, przy wyciąganiu danych używasz już sobie tylko nazw p1 i p2 jako nazw pól.

Nazwa aliasów mogą być dowolne, ważne jednak, by nie kolidowały z nazwami tabel i pól oraz słowami kluczowymi dla mysqla.

-------------------------------------------
Update: Ten post też zmodyfikowałem.
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 - 19:09