gpt4 book ai didi

mysql - 通过合并名为 luckydraw_weekone、luckydraw_weektwo 的三个表来显示用户表中现有的电子邮件,所有参与者的字段都为电子邮件

转载 作者:行者123 更新时间:2023-11-29 03:36:22 24 4
gpt4 key购买 nike

$query = "SELECT GROUP_CONCAT(  luckydraw_weekone.Email),
GROUP_CONCAT(luckydraw_weektwo.Email),
GROUP_CONCAT(participants.Email)
FROM luckydraw_weekone
LEFT JOIN luckydraw_weektwo
ON luckydraw_weekone.id = luckydraw_weektwo.id
LEFT JOIN participants ON luckydraw_weekone.id = participants.id";

$qry_result = mysql_query($query) or die(mysql_error());
$display_string = "<table border=\"1\">";
$display_string = "<table border=\"1\">";
$display_string .= "<tr>";
$display_string .= "</tr>";

while($row = mysql_fetch_array($qry_result)){
$display_string .= "<tr>";
$display_string .= "<td>$row[0]</td>";
$display_string .= "<td>$row[1]</td>";
$display_string .= "<td>$row[2]</td>";
$display_string .= "</tr>";
$query2 = "SELECT * FROM users WHERE mail='.$row[0].' OR mail='.$row[1].' OR mail='.$row[2].'";
$qry_result2 = mysql_query($query2) or die(mysql_error());
$display_string_user = "<table border=\"1\">";
while($row2 = mysql_fetch_array($qry_result2)){
$display_string_user .= "<tr>";
$display_string_user .= "<td>$row[0]</td>";
$display_string_user .= "<td>$row[1]</td>";
// and all details you want to add
$display_string_user .= "</tr>";
}
}
$display_string .= "</table>";
$display_string_user .= "</table>";
echo $display_string;
echo $display_string_user;

最佳答案

试试这个:

SELECT DISTINCT u.mail
FROM users u
INNER JOIN (SELECT email FROM luckydraw_weekone
UNION
SELECT email FROM luckydraw_weektwo
UNION
SELECT email FROM participants
) AS A ON u.mail = A.email

关于mysql - 通过合并名为 luckydraw_weekone、luckydraw_weektwo 的三个表来显示用户表中现有的电子邮件,所有参与者的字段都为电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21018396/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com