Jump to content

Don't show duplicates on Mysql result


Julian

Recommended Posts

Hi guys

I 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

[quote author=Julian link=topic=114876.msg467509#msg467509 date=1163458890]
Hi guys

I 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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.