Last post Jun 23, 2013 02:55 AM by syed amjad
Jun 22, 2013 07:13 AM|Yaswanth Bobba|LINK
I have requirement to get a data from mysql server using select statement.
I have table with data as below
In gridview I should get the record only once.
Please help me.
table name is noofCLs
empid emailid name leaves month year
Jun 22, 2013 07:33 AM|mamun22s|LINK
Using distinct on your select statement will solve your proble.
Select DISTINCT col1,col2...from noofCLs
Jun 22, 2013 07:40 AM|JammoD|LINK
The data you have there will now allow you to get the record only once, as using a distinct on them columns will still give you the same output as you have.
Are all the columns required in the GridView?
Jun 22, 2013 07:45 AM|Yaswanth Bobba|LINK
Firstly thanks for your reply. But by using Distinct we will not get the data only once because the month or leaves or year may differ with the same empid,name,emailid. so we get it twice.
Jun 22, 2013 07:49 AM|Yaswanth Bobba|LINK
As explained inabove post i will get the data how many times it is there in the database. Because distincit works if all the columns in the row is equal to the other row. If any one column data is changed then it will be repeated.
Jun 22, 2013 06:26 PM|Lannie|LINK
Since each person can have more than one record, with modifiers like date,
which record do you want to keep.
The one with the latest date? The one with the highest leave value?
Too bad MySql is a bit sparse in commands for analytics with partitioning, row ordering, etc.
Jun 23, 2013 02:55 AM|syed amjad|LINK
select distinct empid,emailid,name,leaves,month,year from noofCLs