Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQL Query

Posted on 2006-06-14
2
Medium Priority
?
273 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 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

886 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