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 Link to comment https://forums.phpfreaks.com/topic/120809-solved-identifying-multiple-results-as-one/ 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. Link to comment https://forums.phpfreaks.com/topic/120809-solved-identifying-multiple-results-as-one/#findComment-622731 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! Link to comment https://forums.phpfreaks.com/topic/120809-solved-identifying-multiple-results-as-one/#findComment-623037 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.