can you please give an example of an application where actually doing this has any meaning whatsoever?
I have a search form where it searches my students table by studentid,first name, middle name, etc...It just came to my mind that when the user choose to search by studentid i want the result to be all student where their studentid contains the search key. So, if i have 3 student id (198,199,200)
and in my search key i have a value of %1% the search result should be student with studentid 198 and 199..Hope you get my point.
where the result to be not exact of what he/she typed but i want a the result to be
I suppose you could convert the type to string and then use the like clause
where cstr(myintegercolumn) like "*1*"
but that would be both nasty and inefficient, and certainly shouldn't get any credits in a piece of homework
nasty because you are converting from one datatype to another uneccesarily in a query
inefficient because the the db engine will not be able to take advantage of any indexes, and will have to do a tablescan.
Ideally, the branch number would be in a different field.
You could also, in your case, perform a union of several different queries (one for each branch number) where you subtract 100000 (for the first Branch) 200000 (for the second branch) etc, where the result of the subtraction is 31100
The union might be slower than casting the integer as a string, but I wouldn't think so...
"Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
"I have my standards. They may be low, but I have them!" - Bette Middler
"It's a book about a Spanish guy named Manual. You should read it." - Dilbert