Solved

SQL Query

Posted on 2006-06-14
2
231 Views
Last Modified: 2010-04-23
Hey,

in sql server I have two tables. First table is Items. It has two fields, ItemName and ItemCategory. I have a second table, called Categories. It has two fields, Category and AddToList. I want to write ONE query that selectes all Items where the AddToList boolean of the ItemCategory is set to 1. How can I do this? Redesigning the tables is not an option.

e.g.:
Item
====
ItemName: Ventureli
ItemCategory: BIKE
ItemName: Porsche
ItemCategory: CAR
ItemName: BMW
ItemCategory: CAR

ItemCategory
============
Category: BIKE
AddToList: 0
Category: CAR
AddToList: 1

Output of query should be Porsche and BMW.
0
Comment
Question by:tsay
2 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 500 total points
ID: 16901690
Hi tsay,

Select * From Items I Inner Join ItemCategory IC On I.ItemCategory = IC.Category Where IC.AddToList = 1

Should do it.

Tim Cottee
0
 
LVL 5

Author Comment

by:tsay
ID: 16901958
Perfect, tnx
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now