Opencart从3个表中检索数据

时间:2014-02-26 05:18:12

标签: php mysql opencart

你好我有这个问题:

    $sql = "SELECT email_id as name,competition_rate as rate, competition.competition_id, competition.end_date 
FROM " . DB_PREFIX . "competition_winners as competition_winners, 
     ". DB_PREFIX . "competition as competition,
    ". DB_PREFIX . "customer as customer

WHERE competition.competition_id = competition_winners.competition_id and customer.email=competition_winners.email_id";

我需要从table costumer中检索另一行comptition_rate。我正在使用opencart,将它显示为与客户电子邮件显示为名称的同一行将更加丰富。它是否具有可能性以及如何成为圆顶?

P.S。稍微更改了代码,但我无法仅显示所有结果,只有competition_rate或电子邮件。

2 个答案:

答案 0 :(得分:0)

  $sql = "SELECT email_id as name,customer.comptition_rate as newcomrate,competition_rate as rate, competition.competition_id, competition.end_date 
FROM " . DB_PREFIX . "competition_winners as competition_winners, 
     ". DB_PREFIX . "competition as competition,
    ". DB_PREFIX . "customer as customer WHERE competition.competition_id = competition_winners.competition_id and customer.email=competition_winners.email_id";

尝试使用此查询,您将获得有关此newcomrate字段

的数据

答案 1 :(得分:0)

试试这个:

 $sql = "SELECT email_id as name,customer.comptition_rate as rate, competition.competition_id, competition.end_date  FROM " . DB_PREFIX . "competition_winners as competition_winners, ". DB_PREFIX . "competition as competition, ". DB_PREFIX . "customer as customer WHERE competition.competition_id = competition_winners.competition_id and customer.email=competition_winners.email_id";

度过美好的一天!!