I have this two tables:
data
id |email
_
1 |xxx@gmail.com
2 |yyy@gmial.com
3 |zzzgimail.com
errors
_
error |correct
@gmial.com|@gmail.com
gimail.com|@gmail.com
How can I select from data all the records with an email error? Thanks.
Would do it, however doing a LIKE with a wildcard at the start of the value being matched on will prevent an index from being used so you may see poor performance.
An optimal approach would be to define a computed column on the data table, that is the REVERSE of the email field and index it. This would turn the above query into a LIKE condition with the wildcard at the end like so:
In this case, performance would be better as it would allow an index to be used.
I blogged a full write up on this approach a while ago here.