I have table (notes_subject) structure -
+--------------+-------------+------+-----+---------+----------------+
| Field        | Type        | Null | Key | Default | Extra          |
+--------------+-------------+------+-----+---------+----------------+
| id           | int         | NO   | PRI | NULL    | auto_increment |
| user_id      | int         | NO   |     | NULL    |                |
| note_id      | varchar(25) | NO   | MUL | NULL    |                |
| subject_name | text        | NO   |     | NULL    |                |
+--------------+-------------+------+-----+---------+----------------+
and data stored in this table -
+----+---------+--------------+--------------+
| id | user_id | note_id      | subject_name |
+----+---------+--------------+--------------+
| 10 |       2 | UdMs870BSswp | CN           |
| 12 |       2 | 8stMvslwIGr2 | CN           |
| 13 |       2 | PB3KNbbFkaUm | cn           |
+----+---------+--------------+--------------+
Note : CN and cn (lowercase) are different.
I want to count the occurence of each subject_name by user_id in this table. So I run query -
SELECT subject_name, COUNT(subject_name) 
FROM notes_subject where user_id=2 GROUP BY subject_name;
and it fetched -
+--------------+---------------------+
| subject_name | COUNT(subject_name) |
+--------------+---------------------+
| CN           |                   3 |
+--------------+---------------------+
But this is not correct result because CN and cn are different.
and I also want id, user_id, note_id in the result.
 
     
     
    