使用while
循环查看所有表字段值,但重复相同的值多次。
如何解决它......? 请任何人帮帮我?
$tender_select_query ="SELECT * FROM new_tender_one,new_tender_two,new_tender_three,new_tender_four WHERE new_tender_one.id = new_tender_two.tender_id AND new_tender_one.id = new_tender_three.tender_id AND new_tender_one.id = new_tender_four.tender_id";
$tender_select_result =mysql_query($tender_select_query);
while($tender_row = mysql_fetch_assoc($tender_select_result)){
$id =$tender_row['id'];
$work_name =$tender_row['work_name'];
$procuring_entity =$tender_row['procuring_entity'];
$reference_no =$tender_row['reference_no'];
$procurement_method =$tender_row['procurement_method'];
$bid_eligibility =$tender_row['bid_eligibility'];
$last_date =$tender_row['last_date'];
$pre_tend_info =$tender_row['pre_tend_info'];
$comp_work =$tender_row['comp_work'];
$tend_security =$tender_row['tend_security'];
$tend_instruction =$tender_row['tend_instruction'];
$tend_invite =$tender_row['tend_invite'];
$cont_details =$tender_row['cont_details'];
$publish_date =$tender_row['publish_date'];
$tender_status =$tender_row['tender_status'];
$tender_id =$tender_row['tender_id'];
$tender_type =$tender_row['tender_type'];
$tender_type_subcat =$tender_row['tender_type_subcat'];
$item_name =$tender_row['item_name'];
$item_description =$tender_row['item_description'];
$item_offer =$tender_row['item_offer'];
$quantity =$tender_row['quantity'];
$unit_type =$tender_row['unit_type'];
$required_name =$tender_row['required_name'];
答案 0 :(得分:1)
问题在于您使用的query
。
如果您在tender_id
或new_tender_one
左右拥有相同的new_tender_two
,您肯定会获得多行。
<强> new_tender_one
强>
id | tender_title
1 | tender_1
2 | tender_2
<强> new_tender_two
强>
tender_id | tenderer_name
1 | smith
1 | john
2 | paul
<强> result
强>
id | tender_title | tender_id | tenderer_name
1 | tender_1 | 1 | smith
1 | tender_1 | 1 | john
2 | tender_2 | 2 | paul
确保表tender_id
,new_tender_two
,new_tender_three
中没有重复new_tender_four
。
如果有,则必须使用子查询。然后,您需要知道其他record
所需的tables
。 (例如:id 1
smith
或john
)。