Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium



Posted on 2011-04-26
Medium Priority
Last Modified: 2012-05-11
I think I need a subquery here, but I do not know for sure and I have no experience with them. I have a SQL Server 2005 database. I need to create a view that will return all of the records with a certain status that I'm responsible for. My responsibility is determined by the code the record is assigned that conincides with the codes I'm responsible for. There are 100 different codes, and I can me assigned to any number fo them. So the main record table has 1500 records in it. Each record has a status(1, 2, 3, 4) and a code(a, b, c, d, etc.). I am assigned to 5 different codes (a, b, c, d, e). I want to return any record with a status of 1 in any of the codes I'm assigned to. What is the best way to do this? I hope this is clear. Thanks
Question by:dodgerfan
LVL 15

Accepted Solution

dirknibleck earned 800 total points
ID: 35470346
Here's an example that should work...

SELECT main_table.* FROM main_table, my_codes WHERE main_table.code = my_codes.code AND my_codes.person = me AND main_table.status = 1

Open in new window

LVL 41

Assisted Solution

Sharath earned 800 total points
ID: 35470795
Post the table structure, sample data and the expected result.

I am assuming you have one table and want the data from that table for your codes and stats = 1.
select * from tblMain where code in ('a','b','c','d','e') and status = 1 

Open in new window

LVL 21

Assisted Solution

by:Alpesh Patel
Alpesh Patel earned 400 total points
ID: 35473712
Select * from Table where Status = 1 and code in (a, b, c, e, f)

Featured Post

Independent Software Vendors: 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

Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
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…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

580 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