Faisal Faisal - 3 months ago 9
MySQL Question

How to Retrieve data from two table by arranging dates from both table

I have 2 tables
1.Trans_Credit
Trans_Credit

2.Trans_Debit
enter image description here

I want to show record like

Record of 252688
Date Transaction Reason Credit_Amount Debit_Amount
8/17/2016 (From)Thowheed Purcase return 2500
8/24/2019 (From)Mohamed Balance Money 1000
08/11/2016 (To)Thowheed purchase 2500
8/20/2016 (To)Mohamed Salary 3000
8/14/2016 (To)Thowheed Expanse 5000


as well as i want to arrange date by desc
I am using asp.net and sql server

Answer

You need to restructure the tables. Why you need 2 table? Use a single table with a "transaction_type" field. e.g. value D for debit, C for credit OR -1 for Debit, 1 for Credit.

In you current structure this record will appear twice :

Mohamed        Salary                         3000
Comments