In a sql based query, I need to check that the persons I select from data should have a cell phone with area code 256. How 开发者_开发问答do we check this? I have cell phone numbers as BIGINT.
have you tried simple soln like
mysql:
select * from table where cellno like '256%'
something like this:
select if(substr( convert(<your cell phone field>, char(20)), 1,3) = '256', 1, 0)
select if(substr( convert(25746744073709551615, char(20)), 1,3) = '256', 1, 0)
or you could use like:
select if(convert(25646744073709551615, char(20)) like '256%', 1, 0)
I assume you mean MySql 5.1.
In any case,
Select * from persons where persons.cellphonenumber % 10000000 == 256
Or something similar with the modulus operator.
精彩评论