Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Microsoft SQL Server > Re: Selecting s...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 5 Topic 11024 of 11517
Post > Topic >>

Re: Selecting several types

by Ed Murphy <emurphy42@[EMAIL PROTECTED] > May 7, 2008 at 08:32 PM

--CELKO-- wrote:

> CREATE TABLE ItemClassifications
> (item_id CHAR(15) NOT NULL
>    REFERENCES Inventory (item_id)
>    ON DELETE CASCADE
>    ON UPDATE CASCADE,
>  item_type INTEGER NOT NULL
>    REFERENCES ItemTypes(item_type)
>    ON UPDATE CASCADE,
>  PRIMARY KEY (item_id, item_type));
> 
>>> Now I want to select all the items of type 100 or 200...<<
> 
>  SELECT DISTINCT item_id
>    FROM Inventory
>   WHERE item_type IN (100, 200);

s/Inventory/ItemClassifications/

This will work if all you need is item_id.  If you need some data from
the Inventory table as well, then use Plamen's or Erland's approach.
 




 5 Posts in Topic:
Selecting several types
Danny <adler.danny@[EM  2008-05-07 06:00:30 
Re: Selecting several types
"Plamen Ratchev"  2008-05-07 10:17:20 
Re: Selecting several types
--CELKO-- <jcelko212@[  2008-05-07 13:05:28 
Re: Selecting several types
Ed Murphy <emurphy42@[  2008-05-07 20:32:57 
Re: Selecting several types
Erland Sommarskog <esq  2008-05-07 21:46:29 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Dec 3 0:49:52 CST 2008.