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
 SQL Server Development (2000)
 Issue with a select statement

Author  Topic 

nhaas
Yak Posting Veteran

90 Posts

Posted - 2007-12-05 : 13:11:09
I am trying to find all match critera with out KEY0 that starts with was and a Settype that starts with a '*". but In my query always comes up with a mixture of was and *.

What am I doing wrong here?

thanks


SELECT KEY0, BU + '-' + DIV AS Expr1, TYPE, SETTYPE, FR_GR
FROM dbo.TESIS2
WHERE (type = 'cell') OR
(type = 'cel') OR
(type = 'cdma') OR
(type = 'gprs')
ORDER BY BU, DIV, KEY0;

(SELECT KEY0, BU, DIV AS Expr1, TYPE, SETTYPE, FR_GR
FROM dbo.TESIS2
WHERE (settype NOT LIKE '*%') AND (KEY0 NOT LIKE 'WAS%'))

X002548
Not Just a Number

15586 Posts

Posted - 2007-12-05 : 13:26:18
want to post some sample data and what the expected results should be



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

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-12-05 : 13:28:44
[code]SELECT KEY0,
BU + '-' + DIV AS Expr1,
TYPE,
SETTYPE,
FR_GR
FROM dbo.TESIS2
WHERE type IN ('cell', 'cel', 'cdma', 'gprs')
ORDER BY BU,
DIV,
KEY0

SELECT KEY0,
BU + '-' + DIV AS Expr1,
TYPE,
SETTYPE,
FR_GR
FROM dbo.TESIS2
WHERE NOT (settype LIKE '*%' OR KEY0 LIKE 'WAS%')[/code]


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

nhaas
Yak Posting Veteran

90 Posts

Posted - 2007-12-05 : 13:47:33
I dont want to see
was 414-4259 8930-0000 CEL *MOTQ FR804610 (was and *)
but
414-4259 8930-0000 CEL *MOTQ FR804610
or
was 414-4259 8930-0000 CEL MOTQ FR804610
is fine to see
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-12-05 : 13:50:18
Change the OR to AND?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

nhaas
Yak Posting Veteran

90 Posts

Posted - 2007-12-07 : 12:08:17
Peso, thanks that is what I ended up doing.

thanks for the help, this forum is great!
Go to Top of Page
   

- Advertisement -