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(@SearchTer ms,''), isnull(DESCRIPTION,'')) > 0
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(@SearchTer
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
ASKER
Yes, that is what i need. Row 4 should be retrieved.
Can we have a SQL Function to do so?
Can we have a SQL Function to do so?
ASKER
I want to ensure the range also works.