itdeptvnam
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
Select FieldName & 1 > 0 from tablename
I can't find any documentation on this
I'm using Sybase Sql Anywhere
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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).
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).
ASKER
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.
ASKER
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