Convert Mysql Statement to Mssql Statement

I have the following mysql statement which I need to run on sql server:

select *,
IF(employer_name = ‘ABC Inc’, 100, 0)

  • IF(employer_name LIKE ‘ABC Inc%’, 50, 0)
  • IF(employer_name LIKE ‘A% B% C% I% N% C%’, 42, 0)
  • IF(REPLACE(employer_name, ‘.’, ‘’) LIKE ‘%A%B%C%I%n%c%’, ROUND(40 * (CHAR_LENGTH( ‘ABC Inc’ ) / CHAR_LENGTH( REPLACE(employer_name, ’ ', ‘’) ))), 0)
  • IF(employer_name LIKE ‘ABC% Inc%’, 35, 0)
  • IF( CHAR_LENGTH( TRIM(employer_name)) = CHAR_LENGTH( REPLACE( TRIM(employer_name), ’ ', ‘’)) AND employer_name LIKE BINARY ‘A%B%C%I%N%C%’, 32, 0)
  • IF(employer_name LIKE ‘%ABC Inc%’, 30, 0) + 8 * ROUND ((CHAR_LENGTH(employer_name) - CHAR_LENGTH( REPLACE ( LOWER(employer_name), lower(‘ABC Inc’), ‘’))) / LENGTH(‘ABC Inc’)) AS relevance
    from tblEmployer]
    having relevance > 0
    and on_person = 1
    order by relevance desc

It works fine when I run it in phpmyadmin, but not when I try to run it on the sql database due to syntax differences. How would I write this query so it’s SQL compatible?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.