Saturday, February 25, 2012

Query Three Tables - Please Help

Hi

I need to be able pull certain data from our database. I need to find all stockitems (itemid column) that are a T item (binname column) and the memo to be created before the 01/02/2007 (timeanddatecreated column)

To get the data I need - I need to query three tables.

Stockitem - This has the column "itemid"
Stockitemmemo - This has the column "itemid" and "timeanddatecreated"
Binitem - This has the column "itemid" and "binname"

My results must be based on the following criteria.....

All the itemid's have a 'T' in binitem.binname and the memo must have been created before 01/02/2007.

I do have two questions based on the above...

1. Does it make sense what I need?
2. Is it possible

:confused:

Any help would be gratefully received.

Thanks

SimbaOK, help us out.

Read the hint sticky at the top of the forum and post what it asks for|||Possibly a straight Forward


SELECT Stockitem.itemid
,Stockitemmemo.Memo
,Binitem.binname
FROM Stockitem
INNER JOIN Stockitemmemo ON
Stockitem.itemid = Stockitemmemo.itemid
INNER JOIN Binitem ON
Stockitem.itemid = Binitem.itemid
WHERE Binitem.binname LIKE'%T%'
AND Stockitemmemo.timeanddatecreated <'01/02/2007'


Everyones gotta start somewhere :shocked:

Beware If there is NO matching record in either Stockitemmemo or Binitem table then the Stockitem row will NOT be returned - You would need to Consider a LEFT Join to deal with that.

GW

GW|||Your an absolute legend thanks very much! Appreciate your help.

Thanks again.:beer:|||You're Welcome :)|||What's in an absolut legend anyway? Sounds interesting, and my banana Kamikaze's are starting to get me in trouble, so I need a change.|||LOL Tall
What's in an absolut legend anyway? in the UK we call it "Horses for courses"

I'll gladly leave the difficult one's for the u true legends.

Not sure what a banana Kamikaze is but sounds like you need a TallBoy http://www.dbforums.com/showpost.php?p=6287499&postcount=30 - LOL

GW

No comments:

Post a Comment