I have two table account and balance
/---------------------\
| cid | name | mobile |
|---------------------|
| 1 | ABC | 12345 |
|---------------------|
| 2 | XYZ | 98475 |
\---------------------/
/----------------------------\
| date | cid | balance |
|----------------------------|
| 2013-09-19 | 1 | 5000 |
|----------------------------|
| 2013-09-19 | 2 | 7000 |
|----------------------------|
| 2013-09-20 | 1 | 300 |
|----------------------------|
| 2013-09-20 | 2 | 4500 |
|----------------------------|
| 2013-09-21 | 2 | 600 |
\----------------------------/
I would like to join this two table and get the balance of the maximum date for a particular cid.
Output result as -
/--------------------------------------------\
| cid | name | mobile | date | balance |
|--------------------------------------------|
| 1 | ABC | 12345 | 2013-09-20 | 300 |
|--------------------------------------------|
| 2 | XYZ | 98475 | 2013-09-21 | 600 |
\--------------------------------------------/