Sunday, 8 September 2013

Fetching record of integer type Using WHERE clause that matches part of the value provided as input

Fetching record of integer type Using WHERE clause that matches part of
the value provided as input

MySql+java
I want to retrieve records using WHERE clause
column: SecCode int(11) have values like this, 221101101, 221101102,
221302551, so on....
i am passing query as below:
query = "select distinct(SecName) from sector_mst where SecCode Like="+
myvalue +"%"
myvalue has values like 2211, 2212, 2213, and so on....
"I know it is of integer type hence i am getting error"
Also i cannot use make of = operator as SecCode = myvalue... because
221101101 != 2211
can i compare or match only first 4 digits of SecCode (2211...) with
myvalue(2211) and i am not able to figure out any other way to do this....
Thanks...

No comments:

Post a Comment