简体   繁体   English

内部以字符串格式将CSV值连接到php中的MySQL表

[英]inner join CSV values in string format to MySQL table in php

I have an array of email addresses that I need to verify against a DNC table. 我有一系列电子邮件地址,我需要根据DNC表进行验证。 Fairly simple in theory- ready for the twist? 理论上相当简单 - 准备好扭曲? I cannot make a temp table. 我不能制作临时表。 Nor do I wish to issue a SELECT statement for each email. 我也不希望为每封电子邮件发出SELECT语句。 Wouldn't it be unsightly to chain 'OR' statements? 将'OR'语句链接起来不是很难看吗? I would imagine relatively inefficient. 我认为效率相对较低。 Anyone see a clean, efficient way of going about this? 有人看到一个干净,有效的方式来解决这个问题吗?

I'm not sure if this answers your question, but you can use "IN" instead of chaining a bunch of "OR" statements. 我不确定这是否能回答你的问题,但你可以使用“IN”而不是链接一堆“OR”语句。

SELECT *
FROM yourtable
WHERE email IN ('some@email.com', 'another@email.com', 'athird@email.com');

is a much easier way of writing: 是一种更容易的写作方式:

SELECT *
FROM yourtable
WHERE (email = 'some@email.com'
   OR email = 'another@email.com'
   OR email = 'athird@email.com');
$q = '
SELECT *
FROM yourtable
WHERE email IN ("'.implode('","', $yourArray).'")
';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM