Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Elwood
Starting Member
4 Posts |
Posted - 2004-07-01 : 06:04:44
|
| HiI have a query that reads WHERE Rent <= 'varMax'Where varMax is a number entered by the user and Rent is the number in the database, when the user puts in a number with three figures, even though the database contains an entry of 40, it returns no results, any idea why??? |
|
|
ditch
Master Smack Fu Yak Hacker
1466 Posts |
Posted - 2004-07-01 : 06:09:23
|
| Are those numbers varchar or char values or are they numeric?select case when '9' <= '11' then 'Yes' else 'No' endselect case when 9 < = 11 then 'Yes' Else 'No' endDuane. |
 |
|
|
Elwood
Starting Member
4 Posts |
Posted - 2004-07-01 : 06:11:48
|
| Sorry full query should read:SELECT * FROM ROOMS WHERE City LIKE '%varCity%' AND Rent <= 'varMax' |
 |
|
|
ditch
Master Smack Fu Yak Hacker
1466 Posts |
Posted - 2004-07-01 : 06:15:58
|
| I dont understand.Why are you comparing 'varMax' with a number?Duane. |
 |
|
|
Wanderer
Master Smack Fu Yak Hacker
1168 Posts |
Posted - 2004-07-01 : 06:27:01
|
| sounds like you should be changing the Rent column from char to numeric data type.In the meantime, you can probably use:SELECT * FROM ROOMS WHERE City LIKE '%varCity%' AND cast(Rent as int) <= varMaxAssumming that VarMax is an int. Otherwise, cast the rent column to the same data type as the varmax- (dec(10,2) for example.Also, please don't use SElect * ... select the data columns you need from table CITY. You will reduce unnecessary IO and network traffic.CiaO*##* *##* *##* *##* Chaos, Disorder and Panic ... my work is done here! |
 |
|
|
Elwood
Starting Member
4 Posts |
Posted - 2004-07-01 : 06:50:08
|
| Many thanks all, have changed column to numeric, taken the inverted commas of the varMax request and selected only the columns I want.All is now as it should be, thanks guys!! |
 |
|
|
|
|
|
|
|