1

I'm having problem with executing select statement while using match and and/or operators while using parameters.

The statement looks like this:

SELECT ColumnName1, ColumnName2 
FROM TableName 
WHERE TableName MATCH 'ColumnName1:@param1 AND ColumnName2:@param2';

But when I change @param1 and @param2 with real values, for example like this

SELECT ColumnName1, ColumnName2 
FROM TableName 
WHERE TableName MATCH 'ColumnName1:Value AND ColumnName2:Value';

it works fine.

I guess the problem is those single quotes around my AND statement. Is there any way to avoid them but still be able to use and/or operators or is problem somewhere else?

fuzzomorphism
  • 79
  • 1
  • 10

1 Answers1

2

You can't use SQL parameters to replace parts of an argument, but perhaps you may be able to use string concatenation (I didn't test this):

... MATCH 'ColumnName1:' || @param1 || ' AND ColumnName2:' || @param2;

Else you'll have to go the canonical way, build the string in your application and provide it as a single parameter:

... MATCH @param;
Murphy
  • 3,827
  • 4
  • 21
  • 35