Somebody asked me this question a while back. Here is a simple way to match passwords ( handy for CGI/Perl apps ):

If you have a password field in your table which is MD5 encrypted, you can use the following SQL to verify if a user supplied password matches the MD5:

SELECT IF( password = MD5('$password' ), 'yes', 'no' ) FROM my_user_table WHERE username = '$userid'

If the password matches, a 'yes' will be returned.

Note: $password and $userid are variables passed by your app ( in this case Perl variables were used ).

Tested with MySQL 3.23.47 on Linux

Cheers