我正在尝试内部连接来自OS TICKET数据库的3个表。
我使用的代码是$qry = "SELECT qbcd_user_email.address, qbcd_user_email.user_id FROM qbcd_user_email INNER JOIN qbcd_user ON qbcd_user.id = qbcd_user_email.user_id INNER JOIN qbcd_ticket ON qbcd_ticket.user_id WHERE (qbcd_user_email.address = '.$email.') ORDER BY qbcd_ticket.ticket_id DESC";
代码正在返回:
string(287) "SELECT qbcd_user_email.address, qbcd_user_email.user_id FROM qbcd_user_email INNER JOIN qbcd_user ON qbcd_user.id = qbcd_user_email.user_id INNER JOIN qbcd_ticket ON qbcd_ticket.user_id WHERE (qbcd_user_email.address = '.patrick.kershner@gmail.com.') ORDER BY qbcd_ticket.ticket_id DESC"
但它没有在while子句中显示任何内容:
while ($row = mysqli_fetch_assoc($result)){
echo $row['qbcd_ticket.number]."<br>";}
我不确定发生了什么,或者为什么它没有显示结果。
有人可以查看我上面的代码并验证吗?
答案 0 :(得分:0)
尝试将数字添加到所选属性
$qry = "SELECT qbcd_user_email.address, qbcd_user_email.user_id, qbcd_ticket.number FROM qbcd_user_email INNER JOIN qbcd_user ON qbcd_user.id = qbcd_user_email.user_id INNER JOIN qbcd_ticket ON qbcd_ticket.user_id WHERE (qbcd_user_email.address = '.$email.') ORDER BY qbcd_ticket.ticket_id DESC"
答案 1 :(得分:0)
第一个表是:
qbcd_ticket:
rows:
ticket_id | number | user_id | user_email_id | status_id | dept_id | and more...
5 | 762086| 2 | 0 | 1| 1 |
the next is qbcd_user_email
rows:
id | user_id | flags | address
2 | 2 | 0 | example@demo.com
the last is: qbcd_user
id | org_id | default_email_id | status | name | created | updated
2 | 0 | 2 | 0 | Patrick Kershner | 2017-03-03 10:44:28 | 2017-03-03 10:44:28
我需要显示的信息是与客户关联的所有相应的门票,其中=电子邮件地址。
唯一不会更改的静态变量是$_SESSION['user_email'];
,它通过登录成员区域来记录。