I have a mysql table that has typetags for games, like
table game_typetags
:
name typetag
--------- --------
game#1 sports
game#1 soccer
game#2 race
game#2 sports
and another table games
like
name playcount
--------- ---------
game#1 10
game#2 8
And I want to list relevant games (score them with number of common typetags) and sort with playcount.
So I'm trying to get such an array in PHP:
function getSimilarGames($typetags_array)
{
$pdo->query("SELECT * FROM games COUNT (*) AS ???? ORDER BY games.playcount DESC");
}
So that when I call this function with $typetags = [race,sports]
, it should return
name score
____ _____
game#2 2
game#1 1
What query should I use for this? Thanks !