If you asking for a query string to fetch the data and display it on gridview here is the answer.
The better and the simplest approach that I always suggest is to define a DataTable as datasource to the DataGridview and work on the dataTable instance rather than the DataGridView control itself.
the DataTable class has powerfull methods and it directly binds your data to the DataGridView so any changes you made to the dataTable rows/columns it will reflect immediately on the DataGridView. so the steps are
1. Define a dataTable
2. set the above dataTable as dataSource to the dataggridview
3. Prepare the mySQL select statement which satisfies your requirement
ref this link for how to write mySQL statements
http://dev.mysql.com/tech-resources/articles/subqueries_part_1.html[
^]
4.update the dataTable with the select statement result, most probably its a DataSet/DataTable based on how you write your method
5.Thats all your grid will display the table data on completing step 4.
so we have done with display one thing you need to take here is, simply binding the dataTable to datagridview displays the alias name we used in the select statement as Column Name and it automatically populated all the items included in the select statement to the grid which is nasty at times. If you want to configure your datagrid columns so that it displays only columns which you are really interested in. follow the below steps
1. Change the dataGridView.AutoGenerateColumn = false, this will stop adding the columns on updating the select statement
2. Add the columns which you are really interested
3. Set the DataPropertyName as your Alias name from the select statement
which will automatically take the column from the sql table to view