Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 SQL not checking correctly

Author  Topic 

dba123
Yak Posting Veteran

90 Posts

Posted - 2006-02-19 : 21:13:59






Logged In As dba123
My Open Questions (15)
Logout




Page Options
Reload This Question
Databases Area
Send To A Friend
Ask a Question




Search 1M Solutions

Keywords


Advanced Search...




Page Editor
Databases
Lowfatspread



Featured Expert
angelIII
Ask An Expert Now!



Top 15
Overall
Databases


angelIII 568295

Arthur_Wood 437613

jrb1 375876

peter57r 214309

SjoerdVerweij 209177

Lowfatspread 176983

Kevin3NF 162978

jimhorn 155086

rherguth 152602

alanwarren 141875

rafrancisco 141366

acperkins 130867

jdlambert1 130570

arbert 122966

Henka 113516
Hall of Fame



What is your expert ranking?
Topic Area


Certified Expert
Your Level


Get Certified Now
Master 50,000
Guru 150,000
Wizard 300,000
Sage 500,000
Genius 1,000,000




Top 15
Yearly
Databases


angelIII 95753

Arthur_Wood 66989

dmitryz6 49774

jrb1 48871

acperkins 41552

jimhorn 40491

JesterToo 22913

Kevin3NF 20024

oleggold 19154

jimpen 17678

sasapopovic 16970

dqmq 15910

peter57r 14432

rherguth 13618

vadimrapp1 11300
Hall of Fame


Home All Topics Databases Viewing a Question


Search 1,441,058 Solutions
Search Help Restrict to this Topic Area Advanced Search

Title: Check for 2 items in Select
asked by dba123 on 02/19/2006 06:02PM PST
This question is worth 500 Points




I'm trying to check for 2 things

1) If There is a record that exists in phones with good = null or good = 1

AND

2) There is a record that exists in the extradata table with extracode of UU for any records found in #1

this isn't doing it. It's finding a bunch of records but I think it's ignoring the check for extradata table because there is no with ST for this account # so really, this select should be returning nothing:

SELECT 1
from phones p (NOLOCK)
inner join master m on m.number = p.number
INNER JOIN extradata e ON e.number = m.number
where ((p.good is null) or (p.good = 1))
and m.number = 672439
and e.extracode = 'UU'

dba123
Yak Posting Veteran

90 Posts

Posted - 2006-02-19 : 21:16:21
sorry, here's the post:

I'm trying to check for 2 things

1) If There is a record that exists in phones with good = null or good = 1

AND

2) There is a record that exists in the extradata table with extracode of UU for any records found in #1

this isn't doing it. It's finding a bunch of records but I think it's ignoring the check for extradata table because there is no with ST for this account # so really, this select should be returning nothing:

SELECT 1
from phones p (NOLOCK)
inner join master m on m.number = p.number
INNER JOIN extradata e ON e.number = m.number
where ((p.good is null) or (p.good = 1))
and m.number = 672439
and e.extracode = 'UU'
Go to Top of Page
   

- Advertisement -