![](/img/trans.png)
[英]How to import data from a single .csv file and save it in three different tables by mentioning the specific columns
[英]getting specific columns from three tables
我需要通过join从三个表中获取特定的列。每次出错时,我的代码是
$saf=mysqli_query($db , "select pod.mobile, tpaidamount.Aptdate, follow.cent, pdate, time from pod,tpaidamount, follow where tpaidamount.pid = follow.pid and pod.Customer Id = tpaidamount.pid and pod.Customer Id =follow.pid ");
$i=1;
while($sfg=mysqli_fetch_assoc($saf) or die(mysqli_error($db)))
;
?>
pod,tpaidamount,follow are tables and other coloumns
得到错误您的SQL语法有错误。 检查与您的MySQL服务器版本对应的手册以获取正确的语法,以在第1行的'Id = tpaidamount.pid和pod.Customer Id = follow.pid'附近使用
是错字吗? 是setfollowup.pid或follow.pid吗?
select pod.mobile, tpaidamount.Aptdate, follow.cent, <table>.pdate, <table>.time
from pod, tpaidamount, follow
where tpaidamount.pid = follow.pid
and pod.`Customer Id` = tpaidamount.pid
and pod.`Customer Id` = follow.pid
您不应该使用空格创建列名称。 名称:“ pod.Customer Id”是错误的属性名称,您需要避免使用诸如数据类型(或任何SGBD保留字)之类的名称,例如:“ date”,“ time”,“ char”,“ table”,“专栏'....但是,如果需要这样做,请尝试以下SQL:
SELECT p.mobile
, t.Aptdate
, f.cent
, ???.pdate
, ???.`time`
FROM pod AS p
JOIN tpaidamount AS t ON o.`Customer Id` = t.pid
JOIN follow AS f ON t.pid = f.pid ON p.`Customer Id` = f.pid
使用别名可以轻松编码SQL查询。 例如:table_name AS tn,table_a_name AS tan。
! 我建议您看一些基本的SQL课。 祝好运。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.