Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem z zapytaniem
olo707
post 22.08.2014, 10:39:42
Post #1





Grupa: Zarejestrowani
Postów: 77
Pomógł: 0
Dołączył: 30.03.2012

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


Witam

Pomoże mi ktoś z zapytaniem sql
Mam w bazie danych 2 tabelki users i store o następującej strukturze
users
id_users autoincrement primary key
name
lastname
email
password

oraz
store
imageid autoincrement primary key
id_users
filename
folder

DO pobierania danych z obu tabelek używam LEFT OUTER JOIN i to się sprawdza. Problem jest taki że w tabelce store oczywiście może być kilka rekordów z takim samym id_users, jak wówczas pobrać dane w taki sposób aby wyświetlić wszystkie rekordy a jeśli jest kilka rekordów z takim samym id_users w tabelce store zawsze wyświetlić ten ostatnio zapisany w tabelce store

z góry dzięki za pomoc






właściwie to sobie już poradziłem, zapytanie działa oceńcie je
$getdata = mysql_query
("SELECT DISTINCT users.id_users,users.name,users.lastname,users.email, store.imageid,store.id_users, store.filename,store.folder FROM users LEFT OUTER JOIN store ON users.id_users=store.id_users GROUP BY users.id_users DESC,store.imageid DESC HAVING store.id_users is null || store.imageid=(SELECT max( imageid )
FROM store)")
or die (mysql_query());
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
Pyton_000
post 22.08.2014, 11:33:48
Post #2





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

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


A słyszałeś o BBCODE ?
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: 24.07.2025 - 15:34