String comparison equivalence between mysql database and php code String comparison equivalence between mysql database and php code database database

String comparison equivalence between mysql database and php code


Even if you achieve it and confirm by some tests, it may not be reliable due to different internal implementation of php and mysql string comparison.

Unlike integers and mathematical calculations, string comparison is usually implemented in a way to satisfy particular needs and can be biased on different languages and platforms. So, there is no guarantee that they will work exactly the same at all times, given you use two different systems.

Secondly, php would be slower for such operations, as compared to mysql. You can use mysql features to do filtering unique values. For example, you can create a view or temporary table to execute the operation. For example, views and temporary tables are suitable and a proper way to do such operations.

You can read more here and here