Web Development

General discussion


Run two differant queries in one table for two differant table

By pratikgosvami90 ·
I want to run some queries which can help me to get result:

I am new for sql

I have two different tables Item and ItemDynamic

In the Item table I have the columns ItemLookUpcode, ItemID and Total Quantity.

In the Item Dynamic table I have the columns ItemID (same as Item table) and Quantity, StoreID.

I want to result as in one table which can give me ItmLookupCode and Quantity (Item.Quantity - ItemDynamic.Qunatity)

I have tried some queries but not worked out please help me.

Thank you in advance.

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -


by Tony Hopkinson In reply to Run two differant queries ...

select Item.ItemLookUpCode, Item.TotalQuantity - ItemDynamic.Quantity as Quantity
From Item Left Outer Join ItemDynamic on Item.ItemID = ItemDynamic.ItemID

Assuming you want all ItemIDs in Item whether they have a corresponding entry
in itemdynamic
If you only want those with an itemid in ItemDynamic then change Outer to Inner.

This is a good site to learn stuff at.


Related Discussions

Related Forums