sql
Selecting a distinct values and its number of occurrence from database
Selecting a distinct values and its number of occurrence from database using SQL $query=”SELECT DISTINCT(`page_id`), COUNT(page_id) as count FROM tablename group by page_id”;
sql
Selecting all ids(rows) except one id(row) in sql using php
Sample Query, here we select all page ids and its count but id except a particular number, Query inside braces of NOT IN condition: “SELECT `page_id`, COUNT(`page_id`) AS `total` FROM `table.comments` WHERE `page_id` NOT IN ( SELECT `id` FROM pages WHERE `identifier` = ‘$except_id’) GROUP BY `page_id`”