Reference to my previous question.
How to further filter GROUP BY record in mysql? There are three different pages where i will use same query but with different dates as shown below: In week_fallowup.php date range is
s_date= 21/Sept/2015
e_date= 28/Sept/2015
In fornight_fallowup.php date range is
s_date= 29/Sept/2015
e_date= 13/Oct/2015
In month_fallowup.php date range is
s_date= 14/Sept/2015
There are three followup pages Week_followup.php, Fornight_followup.php & Month_followup.php in that i am using below three queries:
///////////// QUERY for week_followup.php \\\\\\\\\\\\\\\\\\\\\
$sql="SELECT * FROM sales_queries AS sq INNER JOIN ( SELECT MAX(Query_id) AS mId FROM sales_queries WHERE follow_up BETWEEN '".$s_date."' AND '".$e_date."' GROUP BY nic_id ) AS subsq ON subsq.mId = sq.Query_id";
///////////// QUERY for fornight_followup.php \\\\\\
$sql="SELECT * FROM sales_queries AS sq INNER JOIN ( SELECT MAX(Query_id) AS mId FROM sales_queries WHERE follow_up BETWEEN '".$s_date."' AND '".$e_date."' GROUP BY nic_id ) AS subsq ON subsq.mId = sq.Query_id";
///////////// QUERY for month_followup.php \\\\\\
$sql="SELECT * FROM sales_queries AS sq INNER JOIN ( SELECT MAX(Query_id) AS mId FROM sales_queries WHERE follow_up > '".$s_date."' GROUP BY nic_id ) AS subsq ON subsq.mId = sq.Query_id";
It works perfectly but when someone fallow query on month page and give date of fallowup in next week, it shows on both pages week and month what i want is, it show only one MAX(Query_id) either it is in week_followup.php, fornight_followup.php or month_followup.php. ONLY MAX(query_id)
Forexample In week_fallowup.php date range is
s_date= 21/Sept/2015
e_date= 28/Sept/2015
In fornight_fallowup.php date range is
s_date= 29/Sept/2015
e_date= 13/Oct/2015
In month_fallowup.php date range is
s_date= 14/Sept/2015
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.