Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQL Query

Posted on 2006-06-14
2
Medium Priority
?
267 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

715 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