I am doing Win-form project with MySQL.
In My Problem is,.. I want to Show very first data in My Project.
I know if the primary key is standard like 1 means its very easy. But in my project that primary key id is changeable one. If ascending or descending is also take all the record and then finely give the result.
I want very first record na?. Is any to Identify the First record Query in MySQL.
My Code –
connection.Open();
command.CommandText = "select student_code from attendance_master where subject_code='" + subcode + "' and period_code='" + percode + "' and date='" + date + "'";
Reader = command.ExecuteReader();
while (Reader.Read())
{
stdcode = Reader[0].ToString();
}
connection.Close();
Or other wise can i find the min value of primary id value and select the particular record. I don’t the this is a best way. But it reduce unwanted execution of records.
Pls give me an IDEA….
Try using the limit statement, Example: