contra10 Posted February 5, 2009 Share Posted February 5, 2009 how can i select more than one distinct i want the name variable and the id <?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("userimages") or die(mysql_error()); $queryi = "SELECT DISTINCT(name) FROM `photoalbum` WHERE `userid` = '$id'"; $resulti = mysql_query($queryi); while($rowid = mysql_fetch_assoc($resulti)) { $ca= "{$rowid['name']}"; $iduu= "{$rowid['paid']}"; echo "<a href='http://localhost/photoalbum/albums.php?alb=$iduu'>$ca</a><br>"; } ?> Link to comment https://forums.phpfreaks.com/topic/143884-selecting-more-than-one-distinct/ Share on other sites More sharing options...
contra10 Posted February 5, 2009 Author Share Posted February 5, 2009 i tried something like this but it doesn't work $queryi = "SELECT DISTINCT(name, paid) FROM `photoalbum` WHERE `userid` = '$id'"; Link to comment https://forums.phpfreaks.com/topic/143884-selecting-more-than-one-distinct/#findComment-754989 Share on other sites More sharing options...
skiingguru1611 Posted February 5, 2009 Share Posted February 5, 2009 Try $queryi = "SELECT DISTINCT name, paid FROM `photoalbum` WHERE `userid` = '$id'"; I've never used DISTINCT, but I think that should work. Link to comment https://forums.phpfreaks.com/topic/143884-selecting-more-than-one-distinct/#findComment-754994 Share on other sites More sharing options...
JonnoTheDev Posted February 5, 2009 Share Posted February 5, 2009 SELECT DISTINCT will only work with an individual field, use a GROUP BY claus Link to comment https://forums.phpfreaks.com/topic/143884-selecting-more-than-one-distinct/#findComment-755158 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.