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 Syntax

Author  Topic 

delaneyjm
Starting Member

1 Post

Posted - 2009-03-06 : 08:29:02
Hello All,

I've got a newbie question for you and I'm out of practice in SQL. I'm trying to modify an SQL query that has multiple AND conditions in my WHERE clause. The modification requires the new condition to be an OR. My existing query is like this:

SELECT * FROM Magicdb._SMDBA_.[Help Desk] WHERE
([Group Name] = 'REG_ATL_IT')
AND ([State:] = 'O')
AND ([Problem Description] LIKE '%atlantic%');


The query needs to be modified so that it would be something to the effect of

SELECT * FROM Magicdb._SMDBA_.[Help Desk] WHERE
([Group Name] = 'REG_ATL_IT')
AND ([State:] = 'O')
AND ([Problem Description] LIKE '%atlantic%')
OR ([Problem Description] LIKE '%426-%');


But that causes errors when trying to run the query. Any thoughts or help are appreciated.

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-03-06 : 08:30:51
whats the error?
Go to Top of Page

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2009-03-06 : 08:35:42
if you're gonna put an OR in there you just need to put brackets in the right place too. something like....

SELECT * FROM Magicdb._SMDBA_.[Help Desk] WHERE
([Group Name] = 'REG_ATL_IT')
AND ([State:] = 'O')
AND (
([Problem Description] LIKE '%atlantic%')
OR ([Problem Description] LIKE '%426-%')
)



Em
Go to Top of Page
   

- Advertisement -