好了,所以我有2個選擇語句:將表格數據與另一個表格數據進行比較的最佳方式是什麼?
SELECT DISTINCT Email
FROM dbo.Customers
WHERE (Email IS NOT NULL)
AND (Email LIKE '%@%')
AND (RIGHT(Email, 4) IN ('.net', '.com', '.org'))
AND (Email NOT LIKE '%@UniformCity.com')
AND (Email NOT LIKE '%@LifeUniform.com')
AND (CHARINDEX('.',Email) <> 1)
AND (RIGHT(RTRIM(Email), 1) <> '.') AND (LEFT(LTRIM(Email), 1) <> '@')
AND (Email not Like '%[`:;_*-,^[^]()+%\/=#-]%' escape '^') order by Email
和
SELECT replace(replace(
replace(
replace(EmailOptOut,'"','')
, ',held','')
, ',unsub','')
, ',confirm','')
as CleanEmail
FROM [LifeMail].[dbo].[EmailOptOuts]
我只想選擇Customers表中的電子郵件,這在EmailOptOuts表都沒有。什麼是達到這個目標的最好方法?我想過使用遊標和循環,但我相信你的專家知道更好的方法。