我有两个表(tbl_CUST,tbl_Total)
tbl_CUST
Name Sex ProductName Price
Jonh M iPhone 6s $ 1200
Smith M iPhone 6 $ 900
Mary F Samsung S7 $ 800
tbl_total (只有一条记录)
Total Date
$2,900 20-05-2016
This the result that I did. But I don't need like that:
Name Sex ProductName Price Total Date
Jonh M iPhone 6s $ 1,200 $2,900 20-05-2016
Smith M iPhone 6 $ 900
Mary F Samsung S7 $ 800
Now I need to combine table and show the result like that:
Name Sex ProductName Price Total Date
Jonh M iPhone 6s $ 1,200 $2,900 20-05-2016
Smith M iPhone 6 $ 900
Mary F Samsung S7 $ 800
So, What's can I do? Please help me! Thanks so much!
答案 0 :(得分:0)
$ sql = mysql_query(tbl_CUST
上的{select * from tbl_Total
内部加入tbl_Total
。Name
= tbl_CUST
。Name
“, $ conn);在
在查询中使用内部联接进行拖动表合并。这里的“NAME”是两个表的条件,其中查询只返回同名记录,只有其他记录是hide。