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
itdeptvnamAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sameer2010Commented:
This is a typical bitwise operation. If Fieldname consists of 1, the result would be 1 else 0.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
wilcoxonCommented:
FieldName & 1 is a bitwise and so it should return either 0 or 1 (1 if FieldName is odd and 0 otherwise).  I'm assuming the > 0 is a shorthand for "select FieldName & 1 where FieldName & 1 > 0" but I've never seen that construct before.
itdeptvnamAuthor Commented:
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
wilcoxonCommented:
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).
itdeptvnamAuthor Commented:
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.