I am stuck on fetching unique data from MySql Database by PHP Distinct
. I want to fetch all the data from the table but in a particular field ' ccTitle ' should remove duplicate entries. My Query is as follows-
"SELECT DISTINCT(*) FROM conferencecreate WHERE ccFlag = 1 AND ccStartingDate >= '$nowTime'"
But it's not working. I discovered Distinct
is working individually for a field. Is there another to solve this issue?
Let me know please.
TQ
You are going to have to SELECT DISTINCT
for each field you want non-duplicated data ..
IE
SELECT DISTICT ON item1,item2 *
FROM table WHERE something = 'something'
You are looking for this query:
SELECT *
TABLE table
GROUP BY column
You can write this query with DISTINCT statement like that:
SELECT DISTINCT ON column *
FROM table
Well, finally I found the appropriate answer for my question. Instead of using distinct , group by can be used to solve this issue.
$q = mysql_query("SELECT * FROM conferencecreate WHERE ccFlag = 1 AND ccStartingDate >= '$nowTime' GROUP BY ccTitle");
It's working for me perfectly.
Thank you all.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.