![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 8 Pomógł: 0 Dołączył: 2.01.2008 Ostrzeżenie: (0%) ![]() ![]() |
Witam mam 3 tablele o zawartości:
CODE -- -- Struktura tabeli dla `db_dane` -- CREATE TABLE `db_dane` ( `id` smallint(6) NOT NULL auto_increment, `user_id` smallint(6) NOT NULL default '0', PRIMARY KEY (`id`) ) TYPE=MyISAM ; -- -------------------------------------------------------- -- -- Struktura tabeli dla `db_ratings` -- CREATE TABLE `db_ratings` ( `rating_id` smallint(5) unsigned NOT NULL auto_increment, `rating_item_id` smallint(5) unsigned NOT NULL default '0', `rating_type` char(1) NOT NULL default '', `rating_user` smallint(5) unsigned NOT NULL default '0', `rating_vote` tinyint(1) unsigned NOT NULL default '0', PRIMARY KEY (`rating_id`) ) TYPE=MyISAM ; -- -------------------------------------------------------- -- -- Struktura tabeli dla `db_users` -- CREATE TABLE `db_users` ( `user_id` smallint(5) unsigned NOT NULL auto_increment, PRIMARY KEY (`user_id`) ) TYPE=MyISAM ; Prosiłbym bardzo aby mi ktoś stworzył funkcję wyświetlającą średnią ocenę na podstawie zmiennej $user_id wziętej z user_id w db_users. Średnia wziętą ze wszystkich pól rating_vote (tzn. SELECT SUM(rating_vote) / COUNT(rating_item_id) ) gdzie rating_item_id zawiera id z db_dane w którym user_id to ta nasza zmienna podawana przy funkcji. Od kilku godzin już się nad tym głowię i niestety brak postępów. Dopiero raczkuję w temacie mysql więc będę za wszelką pomoć wdzięczny |
|
|
![]() |
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 8 Pomógł: 0 Dołączył: 2.01.2008 Ostrzeżenie: (0%) ![]() ![]() |
Ten limit się tam automatycznie pojawia w kodzie bo ja żadnego limitu nie chcę.
Zapytanie jakie podaję: SELECT AVG(rat.rating_vote) FROM ep_ratings rat, ep_poezja poezja GROUP BY poezja.user_id WHERE poezja.user_id = '187' AND poezja.user_id = rat.rating_item_id; CODE zapytanie SQL: Dokumentacja SELECT AVG( rat.rating_vote ) FROM ep_ratings rat, ep_poezja poezja GROUP BY poezja.user_id WHERE poezja.user_id = '187' AND poezja.user_id = rat.rating_item_id LIMIT 0 , 30 MySQL zwrócił komunikat: Dokumentacja #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 'WHERE poezja . user_id = '187' AND poezja . user_id = rat . rating_item_id LIM' at line 1 W ogóle dla mnie bez sensu... Sprawdzałem na 100 sposobów.... |
|
|
![]() ![]() |
![]() |
Aktualny czas: 5.10.2025 - 23:46 |