Wrox Programmer Forums
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 29th, 2007, 03:47 PM
Registered User
 
Join Date: Jun 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Retrieve Query

Hi,
I have a table that has the following str and data
ContainerID, ItemId, DateTime
2, 1, 06/23/2007
3, 2, 06/24/2007

So effectively speaking item 1 is in container 2 which is in container 3.

If I were to retrieve all the containers item 1 is in, what should be the query?
[I need both rows]

Thanks,


 
Old July 4th, 2007, 11:57 AM
Registered User
 
Join Date: Jul 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

you need a recursive procedure

 
Old August 2nd, 2007, 05:47 AM
Registered User
 
Join Date: Aug 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi asterix_thegaul,

Please check whether this query helps

declare @itemId as int
set @itemId=1
select ContainerId from table
where
itemId=@itemId
or
(itemid in (select containerid from table where itemid=@itemId))

Thanks and Regards,
Anju Renjith





Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieve Username Suresh62 Classic ASP Databases 0 March 7th, 2008 01:19 AM
Query to retrieve the first 10 records inserted anup_daware Oracle ASP 0 August 6th, 2007 01:50 AM
how to Retrieve Column Names Using SQL Query saravananedu Oracle 2 September 10th, 2005 01:57 AM
Retrieve the table names from union query. udayanbi Access 0 July 20th, 2005 01:38 AM
Retrieve data Snib C++ Programming 2 November 6th, 2004 11:09 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.