Julian Posted November 13, 2006 Share Posted November 13, 2006 Hi guysI have this query:$colname_sub_select = $row_front['id_packages'];mysql_select_db($database_bb, $bb);$query_sub = sprintf("SELECT id_sub, nights, status, id_packages FROM sub_packages WHERE id_packages = %s AND status=1 ORDER BY nights ASC", $colname_sub_select);$sub = mysql_query($query_sub, $bb) or die(mysql_error());$row_sub = mysql_fetch_assoc($sub);$totalRows_sub = mysql_num_rows($sub);The column nights could have the same same number on many rows.What I'm trying to do is a query that prints the results without the duplicates.Thanks for the help.... always great answers here. :) Link to comment https://forums.phpfreaks.com/topic/27157-dont-show-duplicates-on-mysql-result/ Share on other sites More sharing options...
Eugene Posted November 13, 2006 Share Posted November 13, 2006 [quote author=Julian link=topic=114876.msg467509#msg467509 date=1163458890]Hi guysI have this query:$colname_sub_select = $row_front['id_packages'];mysql_select_db($database_bb, $bb);$query_sub = sprintf("SELECT DISTINCT id_sub, nights, status, id_packages FROM sub_packages WHERE id_packages = %s AND status=1 ORDER BY nights ASC", $colname_sub_select);$sub = mysql_query($query_sub, $bb) or die(mysql_error());$row_sub = mysql_fetch_assoc($sub);$totalRows_sub = mysql_num_rows($sub);The column nights could have the same same number on many rows.What I'm trying to do is a query that prints the results without the duplicates.Thanks for the help.... always great answers here. :)[/quote]That should do it. Link to comment https://forums.phpfreaks.com/topic/27157-dont-show-duplicates-on-mysql-result/#findComment-124149 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.