I am trying to join two tables and in both tables I have 2 same column names like agent_id and date both tables have agent_id and date actually I join tables based on agent_id and now I want to order by date column but as both tables have date column so it's showing that date column twice I want it should be shown once and order by date here is an example of my tables:
Table 1 (sales_report)
date agent_id agent_name agent_commission
01-Jan-2016 1 Jhon 200
02-Jan-2016 2 Smith 250
03-Jan-2016 3 Tracy 150
04-Jan-2016 4 Sam 120
Table 2 (payments)
date agent_id paid
02-Jan-2016 1 200
03-Jan-2016 2 150
04-Jan-2016 3 100
05-Jan-2016 4 50
I tried to join these both tables by agent_id now my question is how can I order by date ?
Here is the query I have:
SELECT *
FROM `sales_report`
INNER JOIN `payments`
ON `sales_report`.`agnt_id`=`payments`.`agnt_id` ORDER BY date