473,320 Members | 1,991 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Is there any way to use LIKe operator with interger values

Hi,
I have an integer field with 10 digit values.I want to allow the user to search with starting numbers say 5 digits.

if the search is for 123 all the numbers starting with 123 should be displayed. Is there any operator similar to LIKE for this purpose?
Feb 20 '07 #1
6 24376
r035198x
13,262 8TB
Hi,
I have an integer field with 10 digit values.I want to allow the user to search with starting numbers say 5 digits.

if the search is for 123 all the numbers starting with 123 should be displayed. Is there any operator similar to LIKE for this purpose?
I've never heard of it. Maybe your design is wrong then. Do you really must have that column as an integer?
Feb 20 '07 #2
Maybe I don't get the problem, but if your values are always 10 digits, then you could do something where you fetch all records with
1230000000<= x <=1239999999
Feb 20 '07 #3
r035198x
13,262 8TB
Maybe I don't get the problem, but if your values are always 10 digits, then you could do something where you fetch all records with
1230000000<= x <=1239999999
I think they want 123, 1234, 123009 e.t.c to be returned as well.
Feb 20 '07 #4
deangc
1
I think they want 123, 1234, 123009 e.t.c to be returned as well.
I think you're probably stuck converting the integer value to a varchar and operating on it as a string.

For example,
WHERE CAST(colname as VARCHAR(10)) LIKE '123%'

Note that depending on your design, this could have performance implications.
Feb 25 '07 #5
WHERE CAST(EMP_id AS VARCHAR(8)) LIKE '24%' really works fine.
Mar 1 '07 #6
r035198x
13,262 8TB
WHERE CAST(EMP_id AS VARCHAR(8)) LIKE '24%' really works fine.
Indeed. It's a good trick for this.
Mar 1 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Paul Davis | last post by:
I'd like to overload 'comma' to define a concatenation operator for integer-like classes. I've got some first ideas, but I'd appreciate a sanity check. The concatenation operator needs to so...
30
by: | last post by:
I have not posted to comp.lang.c++ (or comp.lang.c++.moderated) before. In general when I have a C++ question I look for answers in "The C++ Programming Language, Third Edition" by Stroustrup....
4
by: Chiller | last post by:
Ok, thanks to some good assistance/advice from people in this group I've been able to further develop my Distance class. Since previous posts I've refined my code to accept the unit measurement...
2
by: Charles-Antoine Giuliani | last post by:
Is it possible to overload multiple times operator() ? For example for using one or two arguments ? My visual c++ does not seem to like it : I was trying to implement an arbitrary integer...
24
by: Bangalore | last post by:
Hi all, I have a problem in accessing elements using overloaded operator . Consider, const int SIZE=10; int FALSE=0; class Array { private: int x; public:
40
by: KG | last post by:
Could any one tell me how to reverse the bits in an interger?
22
by: clicwar | last post by:
A simple program with operator overloading and copy constructor: #include <iostream> #include <string> using namespace std; class Vector { private: float x,y; public: Vector(float u, float...
30
by: none | last post by:
I'm trying to overload the = operator using templates, but I have some problems with one of the overloads, I would like to make something like that: intvariable = fooclass; here's a pseudo...
1
by: fabian.lim | last post by:
Hi all, Im having a problem with my code. Im programming a vector class, and am trying to overload the () operator in 2 different situations. The first situation is to assign values, e.g. Y =...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.