SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Multiple Where Clauses
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

gemispence
Yak Posting Veteran

71 Posts

Posted - 02/23/2006 :  10:38:04  Show Profile  Send gemispence an AOL message  Reply with Quote
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 - 02/23/2006 :  10:45:52  Show Profile  Reply with Quote
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

Edited by - X002548 on 02/23/2006 10:46:16
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 02/23/2006 :  10:50:16  Show Profile  Reply with Quote
...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 - 02/23/2006 :  10:52:27  Show Profile  Send gemispence an AOL message  Reply with Quote
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 - 02/23/2006 :  10:53:25  Show Profile  Send gemispence an AOL message  Reply with Quote
Thanks so much got it.
Go to Top of Page

gemispence
Yak Posting Veteran

71 Posts

Posted - 02/23/2006 :  10:57:33  Show Profile  Send gemispence an AOL message  Reply with Quote
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

USA
7423 Posts

Posted - 02/23/2006 :  11:42:04  Show Profile  Visit jsmith8858's Homepage  Reply with Quote
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 - 02/23/2006 :  13:03:38  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.22 seconds. Powered By: Snitz Forums 2000