我有这三张桌子零售商,imovo,rbpos_epos。我所做的是匹配它们,并得到我打印在页面中的结果。
我需要做的是将这些结果插入到一个新表中,我将创建一个“匹配”按钮,该按钮将查询两个表零售商和 imovo,匹配项将转到名为:matching 的新表。
为了避免重复,我需要的是从零售商表和 imovo 中删除匹配的行..
这是我用来匹配的查询:
$data = mysql_query( "select r.`time`, r.`epos_id`, r.`date`,re.`location`,i.`user_id`,i.`mobile_number`,
i.`time`, i.`rbpos_id`, i.`date`
from retailer r
join rbpos_epos re on r.epos_id = re.epos_id
join imovo i on i.rbpos_id = re.rbpos_id
and addtime(r.`time`, '0:0:50') > i.`time`
and r.`time` < i.`time`
and r.`date` = i.`date`;
")
or die(mysql_error());
Print "<table border cellpadding=3>";
Print "<tr>";
Print "<th>Date:</th>
<th>Time</th>
<th>Location</th>
<th>User ID</th>
<th>Mobile Number</th>";
Print "</tr>";
while($info = mysql_fetch_array( $data ))
{
Print "<tr>";
Print " <td>".$info['date'] . "</td>
<td>".$info['time'] . " </td>
<td>".$info['location'] . " </td>
<td>".$info['user_id'] . " </td>
<td>".$info['mobile_number'] . " </td>
</tr>";
}
打印的行是我需要在匹配表中插入的行。谢谢!
我试过这个:
$data = mysql_query( "INSERT INTO Matching(date, time, location, user_id, phone)
SELECT
r.`date`,
`time`,
re.`location`,
i.`user_id`,
i.`mobile_number`
from retailer r
join rbpos_epos re on r.epos_id = re.epos_id
join imovo i on i.rbpos_id = re.rbpos_id
and addtime(r.`time`, '0:0:50') > i.`time`
and r.`time` < i.`time`
and
河。date
= 我。date
; ") 但我得到错误:
Column count doesn't match value count at row 1