2

I've got a query against MySQL database as follow:

SELECT id, md5, 
  WHEN md5 = MD5('abc') THEN 'abc'
  WHEN md5 = MD5('def') THEN 'def'
  ELSE NULL
 END AS identity
FROM url WHERE md5 in (MD5('abc'), MD5('def'));

Is there any way to create a variable of sorts to avoid the repetitions? This has to be done without modifying the database and preferable during this single read. It would also be nice to avoid having to calculate the MD5 twice for each value.

0 Answers0