Link to home
Start Free TrialLog in
Avatar of itdeptvnam
itdeptvnamFlag for United States of America

asked on

sql anywhere query

I want to know how this statement works:
Select FieldName & 1 > 0  from tablename

I can't find any documentation on this
I'm using Sybase Sql Anywhere
ASKER CERTIFIED SOLUTION
Avatar of sameer2010
sameer2010
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of wilcoxon
wilcoxon
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of itdeptvnam

ASKER

it's being used in the Where
Example:
CREATE TABLE #TData(VCode int, Svc int)

INSERT INTO #TData (VCode, Svc) VALUES(1,16)
INSERT INTO #TData (VCode, Svc) VALUES(2,23)
INSERT INTO #TData (VCode, Svc) VALUES(3,3)
INSERT INTO #TData (VCode, Svc) VALUES(4,2)
INSERT INTO #TData (VCode, Svc) VALUES(5,1)
INSERT INTO #TData (VCode, Svc) VALUES(6,0)
INSERT INTO #TData (VCode, Svc) VALUES(7,4)
INSERT INTO #TData (VCode, Svc) VALUES(8,32767)
INSERT INTO #TData (VCode, Svc) VALUES(9,511)
INSERT INTO #TData (VCode, Svc) VALUES(10,275)
INSERT INTO #TData (VCode, Svc) VALUES(11,272)


Select * from #TData

Select (Svc & 1), * from #TData

Select (Svc & 1), * from #TData where (Svc & 1) > 0
The first and second queries make sense.  The third really doesn't make sense as written.  It is equivalent to:

select 1, * from #TData where (Svc & 1) > 0

The where will limit it to only rows where bitweise Svc & 1 = 1 (which could be useful) but the (Svc & 1) in the select part will always be 1 (because of the where clause).
Your right the (Svc & 1) in the select was just for me to see the results it for testing only the real query would not have that in the select insert statement.