Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
01-17-2012, 08:57 PM #1
- Join Date
- Jan 2012
- Thanked 0 Times in 0 Posts
MYSQL query for combining data of two tables sharing Foreign key from a third table
I am trying to combine the data from two tables sales & purchase in one table. Both Sales & Purchase table shares foreign key from third table store.
What is the best way to construct the query to get the results exactly as in results tables. I feel that that the example below is the one most common for any DB user. But I am finding it very difficult to get the expected result.
I have tried select with union but not getting the result as expected.
Please also advise if there is any design flaw in creating the DB design.
The source tables and expected query result table is shown in the image.