此查询创建一个 mysql 视图,该视图在一个表中捕获错误的电子邮件地址格式。因此,如果插入一行rtrrg.com
作为电子邮件,它将被记录在视图中。我的问题是,如何使视图跟踪不止一张表。第二张桌子。
SQL
CREATE VIEW `invalid_emails` AS
select `table_with_email_column`.`email` AS `invalidemail`
from `table_with_email_column`
where ((locate(_latin1'', ltrim(rtrim(`table_with_email_column`.`email`))) <> 0)
or (left(ltrim(`table_with_email_column`.`email`), 1) = _latin1'@')
or (right(rtrim(`table_with_email_column`.`email`), 1) = _latin1'.')
or ((locate(_latin1'.', `table_with_email_column`.`email`,locate(_latin1'@', `table_with_email_column`.`email`)) - locate(_latin1'@', `table_with_email_column`.`email`)) <= 1)
or ((length(ltrim(rtrim(`table_with_email_column`.`email`))) - length(replace(ltrim(rtrim(`table_with_email_column`.`email`)), _latin1'@', _latin1''))) <> 1)
or (locate(_latin1'.', reverse(ltrim(rtrim(`table_with_email_column`.`email`)))) < 3)
or (locate(_latin1'.@', `table_with_email_column`.`email`) <> 0)
or (locate(_latin1'..', `table_with_email_column`.`email`) <> 0));