Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-17-2012, 07:57 PM   PM User | #1
pkjoshi
New to the CF scene

 
Join Date: Jan 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
pkjoshi is an unknown quantity at this point
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.

pkjoshi is offline   Reply With Quote
Reply

Bookmarks

Tags
foreign key, mysql, union

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:50 AM.


Advertisement
Log in to turn off these ads.