PC Review


Reply
Thread Tools Rate Thread

SQL Query Help

 
 
Tom Nowak
Guest
Posts: n/a
 
      7th Apr 2009
I have an ASP.NET Web application that I want to write a query or stored
procedure for.

I want to get the results from two tables. One result set will contain all
the names in one table. The second result set will contain some names from a
second table. Then, I want to display the names that are in the first table
that are NOT in the second table.

Any suggestions would be appreciated.
 
Reply With Quote
 
 
 
 
sloan
Guest
Posts: n/a
 
      7th Apr 2009
You need to report your framework version.
2.0/3.0 3.5 1.1?

Very different answers depending.


"Tom Nowak" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have an ASP.NET Web application that I want to write a query or stored
> procedure for.
>
> I want to get the results from two tables. One result set will contain
> all
> the names in one table. The second result set will contain some names
> from a
> second table. Then, I want to display the names that are in the first
> table
> that are NOT in the second table.
>
> Any suggestions would be appreciated.



 
Reply With Quote
 
 
 
 
Tom Nowak
Guest
Posts: n/a
 
      7th Apr 2009
Sorry.

Visual Web Developer 2005 Express.

Framework version 2.0


"sloan" wrote:

> You need to report your framework version.
> 2.0/3.0 3.5 1.1?
>
> Very different answers depending.
>
>
> "Tom Nowak" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >I have an ASP.NET Web application that I want to write a query or stored
> > procedure for.
> >
> > I want to get the results from two tables. One result set will contain
> > all
> > the names in one table. The second result set will contain some names
> > from a
> > second table. Then, I want to display the names that are in the first
> > table
> > that are NOT in the second table.
> >
> > Any suggestions would be appreciated.

>
>
>

 
Reply With Quote
 
sloan
Guest
Posts: n/a
 
      7th Apr 2009

I would get an IDataReader with 2 result sets.


Make a strong DataSet or a CustomObject, CustomBusinessCollection.

Let's say its employees.


List<Employee> allEmps = new List<Employee>();

//populate allEmps with first resultset from IDataReader

.......

List<Employee> coolEmps = new List<Employee>();
//populate coolEmps with first resultset from IDataReader


Write a "filter" then loop over allEmps...try to find a match in
coolEmps....
if no match, then add it to
List<Employee> unCoolEmps = new List<Employee>();



http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!140.entry

You can find examples there in the project.

CustomerFilter
CustomerController.SerializeCustomers(method)
will show you how to use the filter.

In the example, I'm using the filter so I can add Order(s) to a specific
Customer's list of Orders.


........

You can write a "not exists" clause in TSQL, but then you're hitting the db
3 times for stuff you can figure out with 2 db hits.
Which I would choose last.



With some good TSQL, you can maybe get the cool list and uncool listh with
one hit.

Let's pretend Germans are cool.

Use Northwind

GO

select

CustomerID ,

CompanyName ,

Country ,

--[IsGerman] =

[IsCool] =

CASE

WHEN Country like '%Germany%' then 1

else 0

END

from dbo.Customers















"Tom Nowak" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Sorry.
>
> Visual Web Developer 2005 Express.
>
> Framework version 2.0
>
>
> "sloan" wrote:
>
>> You need to report your framework version.
>> 2.0/3.0 3.5 1.1?
>>
>> Very different answers depending.
>>
>>
>> "Tom Nowak" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> >I have an ASP.NET Web application that I want to write a query or stored
>> > procedure for.
>> >
>> > I want to get the results from two tables. One result set will contain
>> > all
>> > the names in one table. The second result set will contain some names
>> > from a
>> > second table. Then, I want to display the names that are in the first
>> > table
>> > that are NOT in the second table.
>> >
>> > Any suggestions would be appreciated.

>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel with SQL Query (*.sql) and SQL Server =?Utf-8?B?S29kZQ==?= Microsoft Excel Misc 2 8th May 2007 01:10 PM
Subracting One SQL Query from another SQL Query =?Utf-8?B?UGlra3UgQXBpbmE=?= Microsoft Access Queries 3 31st May 2006 01:08 PM
HELP NEEDED FAST!!! HELP HELP HELP HELP HELP HELP FAST HELP NEEDED Jonathan Windows XP General 10 13th Jan 2005 03:22 AM
Sql query from Access returns no records, but SQL Query Analyser d =?Utf-8?B?TWlrZUIgaW4gV0I=?= Microsoft Access Queries 0 14th Dec 2004 04:51 PM
Help! Help! Help! Help! Help! Help! Help! Help! Help! Help! Help! Help! Help! -$- Windows XP Internet Explorer 2 21st Dec 2003 11:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:03 AM.