我有我的MySQL數據庫2個表:PHP選擇形成一個MySQL表和秩序被另一個表
- 客戶
- customer_billing
客戶表有列列
- 序列號
- 公司
的* customer_billing *表有列
- 序列
- customer_seq
我對* customer_billing *表運行一個選擇查詢,然後一段時間內在客戶表中循環選擇查詢,如下所示:
$sql="SELECT *, SUM(quantity*unitprice) as customertotal from customer_billing where resellerid = '' and salesmanid = '' and producttype = '".$_GET["producttype"]."' group by customer_seq ";
$rs=mysql_query($sql,$conn) or die(mysql_error());
while($result=mysql_fetch_array($rs))
{
$sql2="SELECT * from customer where sequence = '".$result["customer_seq"]."' and company_status = '' ";
$rs2=mysql_query($sql2,$conn) or die(mysql_error());
$result2=mysql_fetch_array($rs2);
}
我希望能夠從客戶表順序company ASC
顯示的結果
我已經很明顯這只是訂單嘗試ORDER_BY customer_seq序列號
我也試着這樣做爲了通過company ASC
在客戶表查詢,但這沒有工作要麼
我怎麼能得到這個?
mysql_query自PHP 5.5.0起棄用,並且將來會被刪除。相反,應該使用MySQLi或PDO_MySQL擴展。看到這個http://php.net/manual/en/function.mysql-connect.php –
請提供示例數據和所需的輸出示例(最好的方法是提供[小提琴](http:// sqlfiddle。 com)) –
它不是'order_by'。 –