473,854 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is there any way to use LIKe operator with interger values

2 New Member
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 24571
r035198x
13,262 MVP
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
letmatros
2 New Member
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 MVP
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 New Member
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
rgarrep
1 New Member
WHERE CAST(EMP_id AS VARCHAR(8)) LIKE '24%' really works fine.
Mar 1 '07 #6
r035198x
13,262 MVP
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
8037
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 something like this: 1) e = (a, b, c, d); // concatenate a,b,c,d into e 2) (a, b, c, d) = e; // get the bits of e into a,b,c, and d For example, in the second case, assume that a,b,c,d represent 2-bit integers, and e represents an 8-bit...
30
10476
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. However, I've come upon a question that I can neither answer from "The Book" or a Google search (so yes, at least I RTFBed). I'm hoping that someone in this news group might know the answer. Overloading the Operator Say I want to develop a...
4
1901
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 as a char rather than incorrectly representing it as an int. I've done this because I want to develop the class so that it will be able to convert between values, ie if I add 500 m to 1 km I'd like a correct result given in metres (1500 m in this...
2
2400
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 precision class (I know such libraries already exist) and I wrote the following piece of code : template <typename T> class plus_with_carry { public: plus_with_carry(void) : carry(false) {};
24
2288
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
36515
by: KG | last post by:
Could any one tell me how to reverse the bits in an interger?
22
3635
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 v);
30
340
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 code of what I'm doing: template <class COMPLEXTYPE> class foo
1
1759
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 = X(1,2), the elements 1 and 2 of X gets assigned to Y. In this case, the operator () overload should create a copy that is unmodifiable. In the 2nd case, I want do assign values to elements 1 and 2, e.g. X(1,2) = Y. Then in this case, the values...
0
9752
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10692
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10766
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10373
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7921
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7083
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5946
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4565
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.