Unfortunately it is not possible to store passwords safely with only SQL commands.
To prevent rainbowtable attacks you should add a random salt to the hashing scheme, but this means that you cannot verify the password with SQL alone. You would have to read the salt of every row in the user table and calculate the hashes for comparing.
A safe hash function can be tuned to need a certain amount of time (e.g. 10ms), BCrypt for example has a cost factor. If you have to check every row and every calculation needs some time, you will run into problems if your user table grows.
These are the reasons, why passwords should not be hashed by the database itself, instead do it with your development language. First you have to find the hash and its salt by the given username, afterwards you can verify the password for this single row. For PHP have a look at the function password_hash().