Link to home
Start Free TrialLog in
Avatar of TECH_NET
TECH_NET

asked on

SQL Query not functioning

I have a table with column DESCRIPTION that holds the following values
row 1 >>>>    2.5||~||3.0
row 2 >>>>    4.0||~||5.5
row 3 >>>>    5.5||~||6.5
row 4 >>>>    7.5||~||8.5
The datatype of the column is varchar(50)

I need a query to search the rows for a match.
eg: i wish to search of a value of '5.5' and it  should return 2 rows. ( ie row 2, row 3).


here is my query
SELECT * FROM KEYWORD_FARE_ZONE WHERE
PATINDEX(isnull(@SearchTerms,''), isnull(DESCRIPTION,'')) > 0


ASKER CERTIFIED SOLUTION
Avatar of appari
appari
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TECH_NET
TECH_NET

ASKER

One more question if the value is 8.0 the query does not return any value.

I want to ensure the range also works.

do you mean if 8.0 it should return row 4?
if that is the case you have to write a function to divide the column values in to ranges and the compare the input value.
Yes, that is what i need. Row 4 should be retrieved.

Can we have a SQL Function to do so?