Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Varchar is back

Status
Not open for further replies.

pibo

Programmer
Mar 3, 2001
6
0
0
FR
Hi,

Thanks for your answers. I have found a way to get what I need, but it works only with Char type :

SELECT * FROM table WHERE skill + level >= "4 " + "8 "

Do someone have an idea to use this with Varchar.

PS if i do this with Varchar,
SELECT * FROM table WHERE skill + level >= "4" + "8"
the result will give me all the records with Skill >= "48"...

Thanks
 
What exactly is the problem with what you are trying to do?
I imagine you would want to put cast("4 " + "8 " as numeric). Ben
+61 403 395 052
 
What I want to do is simple : I want to get a Recordset starting with a special skill an level.
Let take another example :
Here are some records :
skill level
"MS" "HIGH"
"MS" "LOW"
"MSE" "LOW"
"XS" "HIGH"

What do I have to write to get all the records after "MS" "HIGH" ?

With CHAR Type, all fields are filled with white char to the max length so my request always works. Is there a solution to make it works with VARCHAR ?
 
So are your table fields varchar?

I take it you want (in above example) all MS, HIGH records rather than all records after that?

What is the importance of using varchar? Ben
+61 403 395 052
 
I would rather like to use varchar to reduce the size of my database.
The Recordset I want to have in my last example should be :
"MS" "LOW"
"MSE" "LOW"
"XS" "HIGH"

 
Hrm .. here's what I just did ..
set nocount on
create table abc (fld1 varchar(3), fld2 varchar(4))
insert into abc (fld1, fld2) values ('MS', 'HIGH')
insert into abc (fld1, fld2) values ('MS', 'LOW')
insert into abc (fld1, fld2) values ('MSE', 'LOW')
insert into abc (fld1, fld2) values ('XS', 'HIGH')
select * from abc where fld1 + fld2 >= 'MS' + 'HIGH'
drop table abc

with the result

fld1 fld2
---- ----
MS HIGH
MS LOW
XS HIGH

That isn't what you were wanting? Ben
+61 403 395 052
 
I'm ok with your sample but the result is not what I was expecting.
Try to do the same test with Char fields, you'll see that you'll get "MSE" "LOW" in your recordset. Because, as MSE is greater that "MS", it have to appear...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top