Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [SQLite][MySQL][SQL]Problem z logika sql
eminiasty
post
Post #1





Grupa: Zarejestrowani
Postów: 267
Pomógł: 0
Dołączył: 11.09.2015

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


  1. SELECT ".$prefix."users.*, ".$prefix."users_info.*, ".$prefix."rank.*
  2. FROM ".$prefix."users
  3. JOIN ".$prefix."users_info
  4. ON ".$prefix."users_info.users_id = ".$prefix."users.id
  5. JOIN ".$prefix."rank
  6. ON ".$prefix."users.rank_id = ".$prefix."rank.id
  7. ORDER BY ".$prefix."users_info.name DESC LIMIT $limit, $onpage";


mam zapytanie jak powyzej teraz taki problem chce pobrac name z tabeli users_info, problem w tym ze w tabeli rank jest tez pole name i po przeficzoraniu tego zapytaniai napisaniu np

echo $r['name']; zwraca sie name z tabeli rank.

jak zwrocic tamto rank z user info?
bo nie moge zrobic $r['user_info.name]; (IMG:style_emoticons/default/questionmark.gif) ?
Go to the top of the page
+Quote Post
CuteOne
post
Post #2





Grupa: Zarejestrowani
Postów: 2 958
Pomógł: 574
Dołączył: 23.09.2008
Skąd: wiesz, że tu jestem?

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


  1. SELECT `c`.`name` AS `dupa`, `j`.`name` AS `cycki` FROM `info` `c`, `info2` `j`

o ile baza pozwala, możesz pominąć ` oraz as
Go to the top of the page
+Quote Post
eminiasty
post
Post #3





Grupa: Zarejestrowani
Postów: 267
Pomógł: 0
Dołączył: 11.09.2015

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


sposob z as - genialne , zapomnialem o nim, masakra (IMG:style_emoticons/default/smile.gif)
czyli musze wymieniac wszystkie pola z users_info jesli ich potrzebuje po przecinku i przy name as ?
blednem bedzie zrobic cos na zasadzie: users_info*, name as dupa?


//
zrobilem tak:
  1. $query2 = "
  2. SELECT ".$prefix."users.*, ".$prefix."users_info.name AS name_users, ".$prefix."rank.*
  3. FROM ".$prefix."users
  4. JOIN ".$prefix."users_info
  5. ON ".$prefix."users_info.users_id = ".$prefix."users.id
  6. JOIN ".$prefix."rank
  7. ON ".$prefix."users.rank_id = ".$prefix."rank.id
  8. LIMIT $limit, $onpage";


i nie wykrywa tego name_users

Ten post edytował eminiasty 23.09.2015, 22:25:40
Go to the top of the page
+Quote Post

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: 17.09.2025 - 14:29