Ternary operator in SQL?

I am working on a search engine (see thread) for a university book store. I was having a problem with relevance but have found a solution (using fulltext searches) to almost everything problem except one:

I would like to include a value that says if the column ‘uni’ is like the specified string then return a value of 2 otherwise 0. This will then be added to the sum of relvancy scores from other fields.

i.e. I would like my total relevance field to be (where “mq” is the university code provided from the search form)

MATCH(title) AGAINST('blah')....+MATCH....+(uni LIKE '%mq%' ? 2 : 0) AS totalRelevance

Is this possible in any way?

change this – (uni LIKE ‘%mq%’ ? 2 : 0)

to this – case when uni LIKE ‘%mq%’ then 2 else 0 end

Thanks r937 - you’re like a walking SQL dictionary :slight_smile: