我有 2 个 MySql 表有一些类似的列(存储相同类型的数据)
例如
,如果tableA
有一些字段为email
, phone
, cellphone
,id
tableB
也有email
, phone
, mobile
,id
等
我想从 tableA 中选择所有用户where email = email or phone=phone or mobile=cellphone or id=id
但是这两个表中的数据都太大了> 100万条记录每个表。
我们能得到的最好的 Sql Query 是什么?
我正在使用的是
SELECT LN.LEADS360ID ,LN.fundingDate,LN.closedDate
FROM fsbcorploan.loan LN inner JOIN fsbcorponline.leads360leads LD ON
LD.RefId = LN.LEADS360ID OR
LD.Email = LN.borrower_email OR
LD.CellPhone = LN.borrower_home_phone OR
LD.CellPhone = LN.borrower_cell_phone OR
LD.DayPhone = LN.borrower_home_phone OR
LD.DayPhone = LN.borrower_cell_phone OR
LD.EveningPhone = LN.borrower_home_phone OR
LD.EveningPhone = LN.borrower_cell_phone
WHERE dateAdded between '11/01/2012 05:10:00' and '12/11/2012 05:10:00'
执行需要 13-15 秒