Jump to content

Recommended Posts

Hi PHP Freaks!

 

I have a problem joining 3 mysql tables together

 

my tables are:

 

games

- id

- name

 

category

- id

- cat

 

rating

- id

- rating

 

I want to merge them together so i can get:

 

- id

- name

- cat

- rating

 

The rating should be used with the AVG function during the JOIN

 

 

I've tried a lot myself but can not make i work

Can somebody write a SQL query that will work?

 

Thanks in advance!

MPVM

Link to comment
https://forums.phpfreaks.com/topic/170533-join-3-sql-select-together/
Share on other sites

games

------

id

cat_id

name

 

category

--------

id

cat

 

rating

-----

game_id

rating

count

 

SELECT games.name, category.*, rating.rating, rating.count
FROM games
LEFT JOIN category ON games.cat_id = category.id
LEFT JOIN rating ON games.id = rating.game_id

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.