Home All Groups Group Topic Archive Search About
Author
25 Aug 2006 5:46 PM
Skip
Hello All,
I am having trouble getting the following to work. What is the syntax
for multiple WHERE's, i need to use both fastener_name and num_action,
eg fastener_name and num_action not in


select fastener_name,num_action from #QA_Fastener_Check_Action
where fastener_name and num_action not in (SELECT [serial number],[NC
Action]
FROM Fastener_Database.dbo.Fastener_DB_Working

Thanks

Author
25 Aug 2006 6:23 PM
Alexander Kuznetsov
use a correlated NOT EXISTS instead
Author
25 Aug 2006 6:24 PM
Jim Underwood
SQL Server does not allow in clause with two columns.  You have to use an
exists or an outer join instead.

select a.fastener_name
,a.num_action
from #QA_Fastener_Check_Action as a
where not exists
(
select 1
FROM Fastener_Database.dbo.Fastener_DB_Working as b
where a.fastener_name = b.[serial number]
and a.num_action = b.[NC Action]
)

OR

select a.fastener_name
,a.num_action
from #QA_Fastener_Check_Action as a
left outer join
Fastener_Database.dbo.Fastener_DB_Working as b
on a.fastener_name = b.[serial number]
and a.num_action = b.[NC Action]
where b.[serial number] is null


Show quote
"Skip" <mike_sylves***@voughtaircraft.com> wrote in message
news:1156527966.070731.75760@m73g2000cwd.googlegroups.com...
> Hello All,
> I am having trouble getting the following to work. What is the syntax
> for multiple WHERE's, i need to use both fastener_name and num_action,
> eg fastener_name and num_action not in
>
>
> select fastener_name,num_action from #QA_Fastener_Check_Action
> where fastener_name and num_action not in (SELECT [serial number],[NC
> Action]
> FROM Fastener_Database.dbo.Fastener_DB_Working
>
> Thanks
>
Author
25 Aug 2006 6:30 PM
Skip
Thanks! Used the JOIN method worked fine.


Jim Underwood wrote:
Show quote
> SQL Server does not allow in clause with two columns.  You have to use an
> exists or an outer join instead.
>
> select a.fastener_name
> ,a.num_action
> from #QA_Fastener_Check_Action as a
> where not exists
> (
> select 1
> FROM Fastener_Database.dbo.Fastener_DB_Working as b
> where a.fastener_name = b.[serial number]
> and a.num_action = b.[NC Action]
> )
>
> OR
>
> select a.fastener_name
> ,a.num_action
> from #QA_Fastener_Check_Action as a
> left outer join
> Fastener_Database.dbo.Fastener_DB_Working as b
> on a.fastener_name = b.[serial number]
> and a.num_action = b.[NC Action]
> where b.[serial number] is null
>
>
> "Skip" <mike_sylves***@voughtaircraft.com> wrote in message
> news:1156527966.070731.75760@m73g2000cwd.googlegroups.com...
> > Hello All,
> > I am having trouble getting the following to work. What is the syntax
> > for multiple WHERE's, i need to use both fastener_name and num_action,
> > eg fastener_name and num_action not in
> >
> >
> > select fastener_name,num_action from #QA_Fastener_Check_Action
> > where fastener_name and num_action not in (SELECT [serial number],[NC
> > Action]
> > FROM Fastener_Database.dbo.Fastener_DB_Working
> >
> > Thanks
> >
Author
25 Aug 2006 7:05 PM
Skip
I need to include a field from b in the result how do I do that, eg
b.[nc action]. The following does not work.

select a.fastener_name,a.action_num,a.program_name,b.[NC Action] from
#QA_Fastener_Check_Action as a " 'join method
Left outer join Fastener_Database.dbo.Fastener_DB_Working as b
on a.fastener_name=b.[serial number] and a.action_num=b.[NC Action]
where b.[serial number] is null

Thanks


Skip wrote:
Show quote
> Thanks! Used the JOIN method worked fine.
>
>
> Jim Underwood wrote:
> > SQL Server does not allow in clause with two columns.  You have to use an
> > exists or an outer join instead.
> >
> > select a.fastener_name
> > ,a.num_action
> > from #QA_Fastener_Check_Action as a
> > where not exists
> > (
> > select 1
> > FROM Fastener_Database.dbo.Fastener_DB_Working as b
> > where a.fastener_name = b.[serial number]
> > and a.num_action = b.[NC Action]
> > )
> >
> > OR
> >
> > select a.fastener_name
> > ,a.num_action
> > from #QA_Fastener_Check_Action as a
> > left outer join
> > Fastener_Database.dbo.Fastener_DB_Working as b
> > on a.fastener_name = b.[serial number]
> > and a.num_action = b.[NC Action]
> > where b.[serial number] is null
> >
> >
> > "Skip" <mike_sylves***@voughtaircraft.com> wrote in message
> > news:1156527966.070731.75760@m73g2000cwd.googlegroups.com...
> > > Hello All,
> > > I am having trouble getting the following to work. What is the syntax
> > > for multiple WHERE's, i need to use both fastener_name and num_action,
> > > eg fastener_name and num_action not in
> > >
> > >
> > > select fastener_name,num_action from #QA_Fastener_Check_Action
> > > where fastener_name and num_action not in (SELECT [serial number],[NC
> > > Action]
> > > FROM Fastener_Database.dbo.Fastener_DB_Working
> > >
> > > Thanks
> > >
Author
25 Aug 2006 7:12 PM
Jim Underwood
You can't include anythign from the second table in the result set, because
your result set only contains rows from table a that do not have matching
rows in table b.  If a matching row does not exist, how can you retrieve a
column from it?

Or am i not understanding what you are asking?

Show quote
"Skip" <mike_sylves***@voughtaircraft.com> wrote in message
news:1156532741.189924.91020@p79g2000cwp.googlegroups.com...
> I need to include a field from b in the result how do I do that, eg
> b.[nc action]. The following does not work.
>
> select a.fastener_name,a.action_num,a.program_name,b.[NC Action] from
> #QA_Fastener_Check_Action as a " 'join method
> Left outer join Fastener_Database.dbo.Fastener_DB_Working as b
> on a.fastener_name=b.[serial number] and a.action_num=b.[NC Action]
> where b.[serial number] is null
>
> Thanks
>
>
> Skip wrote:
> > Thanks! Used the JOIN method worked fine.
> >
> >
> > Jim Underwood wrote:
> > > SQL Server does not allow in clause with two columns.  You have to use
an
> > > exists or an outer join instead.
> > >
> > > select a.fastener_name
> > > ,a.num_action
> > > from #QA_Fastener_Check_Action as a
> > > where not exists
> > > (
> > > select 1
> > > FROM Fastener_Database.dbo.Fastener_DB_Working as b
> > > where a.fastener_name = b.[serial number]
> > > and a.num_action = b.[NC Action]
> > > )
> > >
> > > OR
> > >
> > > select a.fastener_name
> > > ,a.num_action
> > > from #QA_Fastener_Check_Action as a
> > > left outer join
> > > Fastener_Database.dbo.Fastener_DB_Working as b
> > > on a.fastener_name = b.[serial number]
> > > and a.num_action = b.[NC Action]
> > > where b.[serial number] is null
> > >
> > >
> > > "Skip" <mike_sylves***@voughtaircraft.com> wrote in message
> > > news:1156527966.070731.75760@m73g2000cwd.googlegroups.com...
> > > > Hello All,
> > > > I am having trouble getting the following to work. What is the
syntax
> > > > for multiple WHERE's, i need to use both fastener_name and
num_action,
> > > > eg fastener_name and num_action not in
> > > >
> > > >
> > > > select fastener_name,num_action from #QA_Fastener_Check_Action
> > > > where fastener_name and num_action not in (SELECT [serial
number],[NC
> > > > Action]
> > > > FROM Fastener_Database.dbo.Fastener_DB_Working
> > > >
> > > > Thanks
> > > >
>
Author
25 Aug 2006 7:31 PM
Skip
You do understand correctly. But how do I do this, when returning the
result I need to show the difference for informational purposes.


Jim Underwood wrote:
Show quote
> You can't include anythign from the second table in the result set, because
> your result set only contains rows from table a that do not have matching
> rows in table b.  If a matching row does not exist, how can you retrieve a
> column from it?
>
> Or am i not understanding what you are asking?
>
> "Skip" <mike_sylves***@voughtaircraft.com> wrote in message
> news:1156532741.189924.91020@p79g2000cwp.googlegroups.com...
> > I need to include a field from b in the result how do I do that, eg
> > b.[nc action]. The following does not work.
> >
> > select a.fastener_name,a.action_num,a.program_name,b.[NC Action] from
> > #QA_Fastener_Check_Action as a " 'join method
> > Left outer join Fastener_Database.dbo.Fastener_DB_Working as b
> > on a.fastener_name=b.[serial number] and a.action_num=b.[NC Action]
> > where b.[serial number] is null
> >
> > Thanks
> >
> >
> > Skip wrote:
> > > Thanks! Used the JOIN method worked fine.
> > >
> > >
> > > Jim Underwood wrote:
> > > > SQL Server does not allow in clause with two columns.  You have to use
> an
> > > > exists or an outer join instead.
> > > >
> > > > select a.fastener_name
> > > > ,a.num_action
> > > > from #QA_Fastener_Check_Action as a
> > > > where not exists
> > > > (
> > > > select 1
> > > > FROM Fastener_Database.dbo.Fastener_DB_Working as b
> > > > where a.fastener_name = b.[serial number]
> > > > and a.num_action = b.[NC Action]
> > > > )
> > > >
> > > > OR
> > > >
> > > > select a.fastener_name
> > > > ,a.num_action
> > > > from #QA_Fastener_Check_Action as a
> > > > left outer join
> > > > Fastener_Database.dbo.Fastener_DB_Working as b
> > > > on a.fastener_name = b.[serial number]
> > > > and a.num_action = b.[NC Action]
> > > > where b.[serial number] is null
> > > >
> > > >
> > > > "Skip" <mike_sylves***@voughtaircraft.com> wrote in message
> > > > news:1156527966.070731.75760@m73g2000cwd.googlegroups.com...
> > > > > Hello All,
> > > > > I am having trouble getting the following to work. What is the
> syntax
> > > > > for multiple WHERE's, i need to use both fastener_name and
> num_action,
> > > > > eg fastener_name and num_action not in
> > > > >
> > > > >
> > > > > select fastener_name,num_action from #QA_Fastener_Check_Action
> > > > > where fastener_name and num_action not in (SELECT [serial
> number],[NC
> > > > > Action]
> > > > > FROM Fastener_Database.dbo.Fastener_DB_Working
> > > > >
> > > > > Thanks
> > > > >
> >
Author
25 Aug 2006 8:09 PM
Jim Underwood
Well, in the case you described, the difference is that the data in table b
does not exist for the given row.  Do you just want to show the empty
values?

If so, you can do this, but it will only return columns wiht no data...

select a.fastener_name
,a.num_action
,b.fastener_name
,b.num_action
from #QA_Fastener_Check_Action as a
left outer join
Fastener_Database.dbo.Fastener_DB_Working as b
on a.fastener_name = b.[serial number]
and a.num_action = b.[NC Action]
where b.[serial number] is null


Show quote
"Skip" <mike_sylves***@voughtaircraft.com> wrote in message
news:1156534317.598645.62810@i42g2000cwa.googlegroups.com...
> You do understand correctly. But how do I do this, when returning the
> result I need to show the difference for informational purposes.
>
>
> Jim Underwood wrote:
> > You can't include anythign from the second table in the result set,
because
> > your result set only contains rows from table a that do not have
matching
> > rows in table b.  If a matching row does not exist, how can you retrieve
a
> > column from it?
> >
> > Or am i not understanding what you are asking?
> >
> > "Skip" <mike_sylves***@voughtaircraft.com> wrote in message
> > news:1156532741.189924.91020@p79g2000cwp.googlegroups.com...
> > > I need to include a field from b in the result how do I do that, eg
> > > b.[nc action]. The following does not work.
> > >
> > > select a.fastener_name,a.action_num,a.program_name,b.[NC Action] from
> > > #QA_Fastener_Check_Action as a " 'join method
> > > Left outer join Fastener_Database.dbo.Fastener_DB_Working as b
> > > on a.fastener_name=b.[serial number] and a.action_num=b.[NC Action]
> > > where b.[serial number] is null
> > >
> > > Thanks
> > >
> > >
> > > Skip wrote:
> > > > Thanks! Used the JOIN method worked fine.
> > > >
> > > >
> > > > Jim Underwood wrote:
> > > > > SQL Server does not allow in clause with two columns.  You have to
use
> > an
> > > > > exists or an outer join instead.
> > > > >
> > > > > select a.fastener_name
> > > > > ,a.num_action
> > > > > from #QA_Fastener_Check_Action as a
> > > > > where not exists
> > > > > (
> > > > > select 1
> > > > > FROM Fastener_Database.dbo.Fastener_DB_Working as b
> > > > > where a.fastener_name = b.[serial number]
> > > > > and a.num_action = b.[NC Action]
> > > > > )
> > > > >
> > > > > OR
> > > > >
> > > > > select a.fastener_name
> > > > > ,a.num_action
> > > > > from #QA_Fastener_Check_Action as a
> > > > > left outer join
> > > > > Fastener_Database.dbo.Fastener_DB_Working as b
> > > > > on a.fastener_name = b.[serial number]
> > > > > and a.num_action = b.[NC Action]
> > > > > where b.[serial number] is null
> > > > >
> > > > >
> > > > > "Skip" <mike_sylves***@voughtaircraft.com> wrote in message
> > > > > news:1156527966.070731.75760@m73g2000cwd.googlegroups.com...
> > > > > > Hello All,
> > > > > > I am having trouble getting the following to work. What is the
> > syntax
> > > > > > for multiple WHERE's, i need to use both fastener_name and
> > num_action,
> > > > > > eg fastener_name and num_action not in
> > > > > >
> > > > > >
> > > > > > select fastener_name,num_action from #QA_Fastener_Check_Action
> > > > > > where fastener_name and num_action not in (SELECT [serial
> > number],[NC
> > > > > > Action]
> > > > > > FROM Fastener_Database.dbo.Fastener_DB_Working
> > > > > >
> > > > > > Thanks
> > > > > >
> > >
>
Author
25 Aug 2006 8:33 PM
Skip
Not sure if I was clear? There will always be a match on
a.fastener_name = b.[serial number]  but there can be differences in
a.num_action = b.[NC Action] and I want to show the differences. It
works now but it does not show the difference in the action comparison.
Thanks

Jim Underwood wrote:
Show quote
> Well, in the case you described, the difference is that the data in table b
> does not exist for the given row.  Do you just want to show the empty
> values?
>
> If so, you can do this, but it will only return columns wiht no data...
>
> select a.fastener_name
> ,a.num_action
> ,b.fastener_name
> ,b.num_action
> from #QA_Fastener_Check_Action as a
> left outer join
> Fastener_Database.dbo.Fastener_DB_Working as b
> on a.fastener_name = b.[serial number]
> and a.num_action = b.[NC Action]
> where b.[serial number] is null
>
>
> "Skip" <mike_sylves***@voughtaircraft.com> wrote in message
> news:1156534317.598645.62810@i42g2000cwa.googlegroups.com...
> > You do understand correctly. But how do I do this, when returning the
> > result I need to show the difference for informational purposes.
> >
> >
> > Jim Underwood wrote:
> > > You can't include anythign from the second table in the result set,
> because
> > > your result set only contains rows from table a that do not have
> matching
> > > rows in table b.  If a matching row does not exist, how can you retrieve
> a
> > > column from it?
> > >
> > > Or am i not understanding what you are asking?
> > >
> > > "Skip" <mike_sylves***@voughtaircraft.com> wrote in message
> > > news:1156532741.189924.91020@p79g2000cwp.googlegroups.com...
> > > > I need to include a field from b in the result how do I do that, eg
> > > > b.[nc action]. The following does not work.
> > > >
> > > > select a.fastener_name,a.action_num,a.program_name,b.[NC Action] from
> > > > #QA_Fastener_Check_Action as a " 'join method
> > > > Left outer join Fastener_Database.dbo.Fastener_DB_Working as b
> > > > on a.fastener_name=b.[serial number] and a.action_num=b.[NC Action]
> > > > where b.[serial number] is null
> > > >
> > > > Thanks
> > > >
> > > >
> > > > Skip wrote:
> > > > > Thanks! Used the JOIN method worked fine.
> > > > >
> > > > >
> > > > > Jim Underwood wrote:
> > > > > > SQL Server does not allow in clause with two columns.  You have to
> use
> > > an
> > > > > > exists or an outer join instead.
> > > > > >
> > > > > > select a.fastener_name
> > > > > > ,a.num_action
> > > > > > from #QA_Fastener_Check_Action as a
> > > > > > where not exists
> > > > > > (
> > > > > > select 1
> > > > > > FROM Fastener_Database.dbo.Fastener_DB_Working as b
> > > > > > where a.fastener_name = b.[serial number]
> > > > > > and a.num_action = b.[NC Action]
> > > > > > )
> > > > > >
> > > > > > OR
> > > > > >
> > > > > > select a.fastener_name
> > > > > > ,a.num_action
> > > > > > from #QA_Fastener_Check_Action as a
> > > > > > left outer join
> > > > > > Fastener_Database.dbo.Fastener_DB_Working as b
> > > > > > on a.fastener_name = b.[serial number]
> > > > > > and a.num_action = b.[NC Action]
> > > > > > where b.[serial number] is null
> > > > > >
> > > > > >
> > > > > > "Skip" <mike_sylves***@voughtaircraft.com> wrote in message
> > > > > > news:1156527966.070731.75760@m73g2000cwd.googlegroups.com...
> > > > > > > Hello All,
> > > > > > > I am having trouble getting the following to work. What is the
> > > syntax
> > > > > > > for multiple WHERE's, i need to use both fastener_name and
> > > num_action,
> > > > > > > eg fastener_name and num_action not in
> > > > > > >
> > > > > > >
> > > > > > > select fastener_name,num_action from #QA_Fastener_Check_Action
> > > > > > > where fastener_name and num_action not in (SELECT [serial
> > > number],[NC
> > > > > > > Action]
> > > > > > > FROM Fastener_Database.dbo.Fastener_DB_Working
> > > > > > >
> > > > > > > Thanks
> > > > > > >
> > > >
> >
Author
25 Aug 2006 8:41 PM
Jim Underwood
ahhhh....

In that case you might try an inner join instead...

select a.fastener_name
,a.num_action
,b.fastener_name
,b.num_action
from #QA_Fastener_Check_Action as a
inner join
Fastener_Database.dbo.Fastener_DB_Working as b
on a.fastener_name = b.[serial number]
where a.num_action <> b.[NC Action]



Show quote
"Skip" <mike_sylves***@voughtaircraft.com> wrote in message
news:1156538038.262275.226030@i3g2000cwc.googlegroups.com...
> Not sure if I was clear? There will always be a match on
> a.fastener_name = b.[serial number]  but there can be differences in
> a.num_action = b.[NC Action] and I want to show the differences. It
> works now but it does not show the difference in the action comparison.
> Thanks
>
> Jim Underwood wrote:
> > Well, in the case you described, the difference is that the data in
table b
> > does not exist for the given row.  Do you just want to show the empty
> > values?
> >
> > If so, you can do this, but it will only return columns wiht no data...
> >
> > select a.fastener_name
> > ,a.num_action
> > ,b.fastener_name
> > ,b.num_action
> > from #QA_Fastener_Check_Action as a
> > left outer join
> > Fastener_Database.dbo.Fastener_DB_Working as b
> > on a.fastener_name = b.[serial number]
> > and a.num_action = b.[NC Action]
> > where b.[serial number] is null
> >
> >
> > "Skip" <mike_sylves***@voughtaircraft.com> wrote in message
> > news:1156534317.598645.62810@i42g2000cwa.googlegroups.com...
> > > You do understand correctly. But how do I do this, when returning the
> > > result I need to show the difference for informational purposes.
> > >
> > >
> > > Jim Underwood wrote:
> > > > You can't include anythign from the second table in the result set,
> > because
> > > > your result set only contains rows from table a that do not have
> > matching
> > > > rows in table b.  If a matching row does not exist, how can you
retrieve
> > a
> > > > column from it?
> > > >
> > > > Or am i not understanding what you are asking?
> > > >
> > > > "Skip" <mike_sylves***@voughtaircraft.com> wrote in message
> > > > news:1156532741.189924.91020@p79g2000cwp.googlegroups.com...
> > > > > I need to include a field from b in the result how do I do that,
eg
> > > > > b.[nc action]. The following does not work.
> > > > >
> > > > > select a.fastener_name,a.action_num,a.program_name,b.[NC Action]
from
> > > > > #QA_Fastener_Check_Action as a " 'join method
> > > > > Left outer join Fastener_Database.dbo.Fastener_DB_Working as b
> > > > > on a.fastener_name=b.[serial number] and a.action_num=b.[NC
Action]
> > > > > where b.[serial number] is null
> > > > >
> > > > > Thanks
> > > > >
> > > > >
> > > > > Skip wrote:
> > > > > > Thanks! Used the JOIN method worked fine.
> > > > > >
> > > > > >
> > > > > > Jim Underwood wrote:
> > > > > > > SQL Server does not allow in clause with two columns.  You
have to
> > use
> > > > an
> > > > > > > exists or an outer join instead.
> > > > > > >
> > > > > > > select a.fastener_name
> > > > > > > ,a.num_action
> > > > > > > from #QA_Fastener_Check_Action as a
> > > > > > > where not exists
> > > > > > > (
> > > > > > > select 1
> > > > > > > FROM Fastener_Database.dbo.Fastener_DB_Working as b
> > > > > > > where a.fastener_name = b.[serial number]
> > > > > > > and a.num_action = b.[NC Action]
> > > > > > > )
> > > > > > >
> > > > > > > OR
> > > > > > >
> > > > > > > select a.fastener_name
> > > > > > > ,a.num_action
> > > > > > > from #QA_Fastener_Check_Action as a
> > > > > > > left outer join
> > > > > > > Fastener_Database.dbo.Fastener_DB_Working as b
> > > > > > > on a.fastener_name = b.[serial number]
> > > > > > > and a.num_action = b.[NC Action]
> > > > > > > where b.[serial number] is null
> > > > > > >
> > > > > > >
> > > > > > > "Skip" <mike_sylves***@voughtaircraft.com> wrote in message
> > > > > > > news:1156527966.070731.75760@m73g2000cwd.googlegroups.com...
> > > > > > > > Hello All,
> > > > > > > > I am having trouble getting the following to work. What is
the
> > > > syntax
> > > > > > > > for multiple WHERE's, i need to use both fastener_name and
> > > > num_action,
> > > > > > > > eg fastener_name and num_action not in
> > > > > > > >
> > > > > > > >
> > > > > > > > select fastener_name,num_action from
#QA_Fastener_Check_Action
> > > > > > > > where fastener_name and num_action not in (SELECT [serial
> > > > number],[NC
> > > > > > > > Action]
> > > > > > > > FROM Fastener_Database.dbo.Fastener_DB_Working
> > > > > > > >
> > > > > > > > Thanks
> > > > > > > >
> > > > >
> > >
>
Author
25 Aug 2006 10:40 PM
Skip
Jim. Worked great thanks for the help!!


Jim Underwood wrote:
Show quote
> ahhhh....
>
> In that case you might try an inner join instead...
>
> select a.fastener_name
>  ,a.num_action
>  ,b.fastener_name
>  ,b.num_action
> from #QA_Fastener_Check_Action as a
> inner join
> Fastener_Database.dbo.Fastener_DB_Working as b
> on a.fastener_name = b.[serial number]
> where a.num_action <> b.[NC Action]
>
>
>
> "Skip" <mike_sylves***@voughtaircraft.com> wrote in message
> news:1156538038.262275.226030@i3g2000cwc.googlegroups.com...
> > Not sure if I was clear? There will always be a match on
> > a.fastener_name = b.[serial number]  but there can be differences in
> > a.num_action = b.[NC Action] and I want to show the differences. It
> > works now but it does not show the difference in the action comparison.
> > Thanks
> >
> > Jim Underwood wrote:
> > > Well, in the case you described, the difference is that the data in
> table b
> > > does not exist for the given row.  Do you just want to show the empty
> > > values?
> > >
> > > If so, you can do this, but it will only return columns wiht no data...
> > >
> > > select a.fastener_name
> > > ,a.num_action
> > > ,b.fastener_name
> > > ,b.num_action
> > > from #QA_Fastener_Check_Action as a
> > > left outer join
> > > Fastener_Database.dbo.Fastener_DB_Working as b
> > > on a.fastener_name = b.[serial number]
> > > and a.num_action = b.[NC Action]
> > > where b.[serial number] is null
> > >
> > >
> > > "Skip" <mike_sylves***@voughtaircraft.com> wrote in message
> > > news:1156534317.598645.62810@i42g2000cwa.googlegroups.com...
> > > > You do understand correctly. But how do I do this, when returning the
> > > > result I need to show the difference for informational purposes.
> > > >
> > > >
> > > > Jim Underwood wrote:
> > > > > You can't include anythign from the second table in the result set,
> > > because
> > > > > your result set only contains rows from table a that do not have
> > > matching
> > > > > rows in table b.  If a matching row does not exist, how can you
> retrieve
> > > a
> > > > > column from it?
> > > > >
> > > > > Or am i not understanding what you are asking?
> > > > >
> > > > > "Skip" <mike_sylves***@voughtaircraft.com> wrote in message
> > > > > news:1156532741.189924.91020@p79g2000cwp.googlegroups.com...
> > > > > > I need to include a field from b in the result how do I do that,
> eg
> > > > > > b.[nc action]. The following does not work.
> > > > > >
> > > > > > select a.fastener_name,a.action_num,a.program_name,b.[NC Action]
> from
> > > > > > #QA_Fastener_Check_Action as a " 'join method
> > > > > > Left outer join Fastener_Database.dbo.Fastener_DB_Working as b
> > > > > > on a.fastener_name=b.[serial number] and a.action_num=b.[NC
> Action]
> > > > > > where b.[serial number] is null
> > > > > >
> > > > > > Thanks
> > > > > >
> > > > > >
> > > > > > Skip wrote:
> > > > > > > Thanks! Used the JOIN method worked fine.
> > > > > > >
> > > > > > >
> > > > > > > Jim Underwood wrote:
> > > > > > > > SQL Server does not allow in clause with two columns.  You
> have to
> > > use
> > > > > an
> > > > > > > > exists or an outer join instead.
> > > > > > > >
> > > > > > > > select a.fastener_name
> > > > > > > > ,a.num_action
> > > > > > > > from #QA_Fastener_Check_Action as a
> > > > > > > > where not exists
> > > > > > > > (
> > > > > > > > select 1
> > > > > > > > FROM Fastener_Database.dbo.Fastener_DB_Working as b
> > > > > > > > where a.fastener_name = b.[serial number]
> > > > > > > > and a.num_action = b.[NC Action]
> > > > > > > > )
> > > > > > > >
> > > > > > > > OR
> > > > > > > >
> > > > > > > > select a.fastener_name
> > > > > > > > ,a.num_action
> > > > > > > > from #QA_Fastener_Check_Action as a
> > > > > > > > left outer join
> > > > > > > > Fastener_Database.dbo.Fastener_DB_Working as b
> > > > > > > > on a.fastener_name = b.[serial number]
> > > > > > > > and a.num_action = b.[NC Action]
> > > > > > > > where b.[serial number] is null
> > > > > > > >
> > > > > > > >
> > > > > > > > "Skip" <mike_sylves***@voughtaircraft.com> wrote in message
> > > > > > > > news:1156527966.070731.75760@m73g2000cwd.googlegroups.com...
> > > > > > > > > Hello All,
> > > > > > > > > I am having trouble getting the following to work. What is
> the
> > > > > syntax
> > > > > > > > > for multiple WHERE's, i need to use both fastener_name and
> > > > > num_action,
> > > > > > > > > eg fastener_name and num_action not in
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > select fastener_name,num_action from
> #QA_Fastener_Check_Action
> > > > > > > > > where fastener_name and num_action not in (SELECT [serial
> > > > > number],[NC
> > > > > > > > > Action]
> > > > > > > > > FROM Fastener_Database.dbo.Fastener_DB_Working
> > > > > > > > >
> > > > > > > > > Thanks
> > > > > > > > >
> > > > > >
> > > >
> >
Author
26 Aug 2006 2:25 PM
Omnibuzz
Hi Jim,
   long time.. how u doing?? Remember this Dark Omni ;)

--
-Omnibuzz (The SQL GC)

http://omnibuzz-sql.blogspot.com/
Author
28 Aug 2006 12:10 AM
Skip
Omnibuzz,
Do you see a potential problem here?

Omnibuzz wrote:
Show quote
> Hi Jim,
>    long time.. how u doing?? Remember this Dark Omni ;)
>
> --
> -Omnibuzz (The SQL GC)
>
> http://omnibuzz-sql.blogspot.com/
Author
28 Aug 2006 4:32 AM
Omnibuzz
Not at all. Sorry for barging in Skip.. Jim answered your question and hence
I thought I could safely send a msg to Jim without u feeling what the heck am
I doing here :)

Old time pal.. catching up.. thats all...
--
-Omnibuzz (The SQL GC)

http://omnibuzz-sql.blogspot.com/



Show quote
"Omnibuzz" wrote:

> Hi Jim,
>    long time.. how u doing?? Remember this Dark Omni ;)
>
> --
> -Omnibuzz (The SQL GC)
>
> http://omnibuzz-sql.blogspot.com/
>
>
Author
28 Aug 2006 1:44 PM
Jim Underwood
I'm doing well, thanks.  Been busy on a few projects lately and haven't had
time to keep up with the group.  How about you?

Show quote
"Omnibuzz" <Omnib***@discussions.microsoft.com> wrote in message
news:4A54A4B3-E821-4EB8-AD01-073B767B3200@microsoft.com...
> Hi Jim,
>    long time.. how u doing?? Remember this Dark Omni ;)
>
> --
> -Omnibuzz (The SQL GC)
>
> http://omnibuzz-sql.blogspot.com/
>
>
Author
28 Aug 2006 2:44 PM
Skip
Omnibuzz,
Thanks for clearing up.

Jim Underwood wrote:
Show quote
> I'm doing well, thanks.  Been busy on a few projects lately and haven't had
> time to keep up with the group.  How about you?
>
> "Omnibuzz" <Omnib***@discussions.microsoft.com> wrote in message
> news:4A54A4B3-E821-4EB8-AD01-073B767B3200@microsoft.com...
> > Hi Jim,
> >    long time.. how u doing?? Remember this Dark Omni ;)
> >
> > --
> > -Omnibuzz (The SQL GC)
> >
> > http://omnibuzz-sql.blogspot.com/
> >
> >
Author
29 Aug 2006 4:32 AM
Omnibuzz
Doing pretty good.. I wasn't (and yet not) active in the group for the past
two weeks.. Pretty hectic schedule here... If everything goes well, should
come back with a bang from next week on :)
--
-Omnibuzz (The SQL GC)

http://omnibuzz-sql.blogspot.com/

AddThis Social Bookmark Button