MikeDXUNL Posted August 22, 2008 Share Posted August 22, 2008 mysql table: videogames gameid | gamename 1 ffffff 2 gggg 3 hhhh achievements achid | achname | gameid 1 secret 1 2 secret 1 3 destroy.. 1 4 secret 2 5 something 2 6 thisname 3 right now I have <?php $get_achs = mysql_query("SELECT * FROM achievements WHERE achname = 'Secret'") or die(mysql_error()); ?> this will pick out the ach's with the name 'secret' i will use those gameids (from the achievements table) to then search the videogames table and retrieve a game name but I dont want the results of $get_achs to be gameid: 1 gameid: 1 gameid: 2 gameid 1 has two secret achievements so the results will show up twice. i only want gameid 1 to show up once. Help is appreciated. Mike Quote Link to comment Share on other sites More sharing options...
btherl Posted August 22, 2008 Share Posted August 22, 2008 Here is one option <?php $get_achs = mysql_query("SELECT gameid FROM achievements WHERE achname = 'Secret' GROUP BY gameid ORDER BY gameid") or die(mysql_error()); ?> Or in one query to fetch the game names directly.: <?php $get_achs = mysql_query("SELECT v.gamename, v.gameid FROM achievements a JOIN videogames v USING (gameid) WHERE a.achname = 'Secret' GROUP BY v.gamename, v.gameid ORDER BY v.gameid") or die(mysql_error()); ?> All untested unfortunately .. I do not have a mysql installation to test with. Quote Link to comment Share on other sites More sharing options...
MikeDXUNL Posted August 22, 2008 Author Share Posted August 22, 2008 I used the second query and it worked! Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.