View Full Version : need to add DISTINCT to SQL?!
need to add: DISTINCT $tableName.booking_date
to my following SQL line below:
"SELECT COUNT(*) as num FROM $tableName WHERE booking_date BETWEEN '$from' AND '$to'"
07-27-2011, 08:30 PM
I'm sorry, the question doesn't make sense, to me.
Are you saying you want a COUNT for each distinct booking_date??
In that case, you don't want DISTINCT, you want GROUP BY:
$sql = "SELECT booking_date, COUNT(*) as num "
. " FROM $tableName "
. " WHERE booking_date BETWEEN '$from' AND '$to' "
. " GROUP BY booking_date "
. " ORDER BY booking_date';
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.