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.
| Author |
Topic |
|
Vaishu
Posting Yak Master
178 Posts |
Posted - 2008-02-11 : 10:01:42
|
HiI have table with 25 colums. 3 of the colums(Chkflag,BMCHECK,UPDATED) have yes/no data type. What I am trying to do :If chkflag is No value (i.e 0) and BMCHECK or UPDATED has no value then bring one of the field from BMCHECK.quote: SELECT DISTINCT BMCHECK FROM FEEDER WHERE Chkflag = 0 AND BMCHECK = 0 OR UPDATED = 0
I am using the above query in vb.net to look for any of above field is blank or not ticked if the query brings any data THEN---run the other querieselse (There is no data)---do this---Advance thanks |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-02-11 : 10:04:05
|
Learn OPERATOR presedence.SELECT DISTINCT BMCHECK FROM FEEDER WHERE Chkflag = 0 AND (BMCHECK = 0 OR UPDATED = 0) E 12°55'05.25"N 56°04'39.16" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-02-11 : 10:05:41
|
Or this suggestionSELECT DISTINCT BMCHECKFROM FEEDERWHERE Chkflag = 0 AND 0 IN (BMCHECK, UPDATED) E 12°55'05.25"N 56°04'39.16" |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-02-11 : 10:17:53
|
| OrSELECT DISTINCT BMCHECKFROM FEEDERWHERE Chkflag = 0AND CAST(BMCHECK AS int) + CAST(UPDATED AS int) >0 |
 |
|
|
Vaishu
Posting Yak Master
178 Posts |
Posted - 2008-02-11 : 10:25:01
|
Thanks a lot it works.quote: Originally posted by Peso Or this suggestionSELECT DISTINCT BMCHECKFROM FEEDERWHERE Chkflag = 0 AND 0 IN (BMCHECK, UPDATED) E 12°55'05.25"N 56°04'39.16"
|
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-02-12 : 01:03:06
|
quote: Originally posted by Vaishu HiI have table with 25 colums. 3 of the colums(Chkflag,BMCHECK,UPDATED) have yes/no data type. What I am trying to do :If chkflag is No value (i.e 0) and BMCHECK or UPDATED has no value then bring one of the field from BMCHECK.quote: SELECT DISTINCT BMCHECK FROM FEEDER WHERE Chkflag = 0 AND BMCHECK = 0 OR UPDATED = 0
I am using the above query in vb.net to look for any of above field is blank or not ticked if the query brings any data THEN---run the other querieselse (There is no data)---do this---Advance thanks
You need to be very careful when using AND and OR in where clauseAs suggested use proper paranthesis to avoid any improper resultMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|