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
 General SQL Server Forums
 New to SQL Server Programming
 Multiple Where Clauses

Author  Topic 

gemispence
Yak Posting Veteran

71 Posts

Posted - 2006-02-23 : 10:38:04
I'm trying to use multiple where clauses but its not working. I want it to look something like this:

INSERT INTO [USCondex_Development].[dbo].[miamiheraldExceptions]([InvalidEmails], [InvalidAdPrintID], [InvalidPropertyStreetAddress], [InvalidPropertyPrice])
SELECT [AdvertiserEmail],[AdPrintId],[AdvertiserAddress], [PropertyPrice]
FROM [Development].[dbo].[table2]
WHERE advertiseremail is NULL
and WHERE adPrintID is NULL
and WHERE firstinsertdate is NOT NULL
and WHERE propertystreetaddress is NOT NULL
and WHERE propertyprice < 100

But it's not working.

X002548
Not Just a Number

15586 Posts

Posted - 2006-02-23 : 10:45:52
Gemi,

You need to supply more info.

Read the hint link in my sig....



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-02-23 : 10:50:16
...and I need to read these things more closely...(having what the problem though, might have helped)


INSERT INTO [USCondex_Development].[dbo].[miamiheraldExceptions](
[InvalidEmails]
, [InvalidAdPrintID]
, [InvalidPropertyStreetAddress]
, [InvalidPropertyPrice])
SELECT [AdvertiserEmail]
, [AdPrintId]
, [AdvertiserAddress]
, [PropertyPrice]
FROM [Development].[dbo].[table2]
WHERE advertiseremail is NULL
AND adPrintID is NULL
AND firstinsertdate is NOT NULL
AND propertystreetaddress is NOT NULL
AND propertyprice < 100




Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam
Go to Top of Page

gemispence
Yak Posting Veteran

71 Posts

Posted - 2006-02-23 : 10:52:27
I've created an exceptions table to put all the columns from another table into that meet the criteria below in the WHERE CLAUSES, but the syntax below is not accurate as it pertains to the WHERE clauses:

INSERT INTO [USCondex_Development].[dbo].[miamiheraldExceptions]([InvalidEmails], [InvalidAdPrintID], [InvalidPropertyStreetAddress], [InvalidPropertyPrice])
SELECT [AdvertiserEmail],[AdPrintId],[AdvertiserAddress], [PropertyPrice]
FROM [Development].[dbo].[table2]
WHERE advertiseremail is NULL
and WHERE adPrintID is NULL
and WHERE firstinsertdate is NOT NULL
and WHERE propertystreetaddress is NOT NULL
and WHERE propertyprice < 100
Go to Top of Page

gemispence
Yak Posting Veteran

71 Posts

Posted - 2006-02-23 : 10:53:25
Thanks so much got it.
Go to Top of Page

gemispence
Yak Posting Veteran

71 Posts

Posted - 2006-02-23 : 10:57:33
Wait I'm sorry that's not quite it. I don't want the AND operator b/c I don't want to match up the value to each of the AND's, I want the statement to evaluate different columns w/ different criteria...hence multiple WHERE clauses. thanks.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2006-02-23 : 11:42:04
Then it sounds like you might want OR in some cases.

you need to state your criteria clearly before we can help you write it.

Understanding boolean logic is a key to using SQL Server. My advice: make sure you know how AND, OR and NOT all work, how and when to parenthesis, and so on, before progressing too much further with SQL.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-02-23 : 13:03:38
Please read my first reply and read the hint link in my sig.

We need the table DDL, sample Data and what the expected results should be...in the form in the link so we don't have retypr everything..

Thanks



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam
Go to Top of Page
   

- Advertisement -