我有4张桌子:
clients, pricelist, result and result_details
我想要生成一个transaction_id, name, test_name and result
出现在其上的表单。我为name
做了一个选择,但我找不到test_name
和result
的选择。
我想要这样的东西[pdf] [5]
$result=mysqli_query($con,"SELECT r.transaction_Id,r.client_id,r.result_id,r.test_id,t.test_id,t.result,p.test_id,p.Name,c.Id,c.surName,c.firstName,c.dob,c.Gender FROM result r
JOIN result_details t
on r.test_id = t.test_id
left JOIN pricelist p ON r.test_id = p.test_id
left JOIN clients c ON r.client_id = c.Id")or die(mysqli_error());
$r=mysqli_query($con,"SELECT DISTINCT id,firstName,surName,Gender,dob FROM clients join result WHERE result.client_id=clients.Id")or die(mysqli_error());
while ($row = mysqli_fetch_array ($r)) {
$id=$row['id'];
$clientfirstname=$row['firstName'];
$surname=$row['surName'];
$gender=$row['Gender'];
$dob=$row['dob'];
$t=mysqli_query($con,"SELECT transaction_Id FROM transaction WHERE clientId=$id") or die(mysqli_error());
while ($test = mysqli_fetch_array ($t)) {
$transaction=$test['transaction_Id'];
$m=mysqli_query($con,"SELECT test_id,result_id from result where client_id=$id")or die(mysqli_error());
while ($q = mysqli_fetch_array ($m)) {
$test_id=$q['test_id'];
$result_id=$q['result_id'];
$z=mysqli_query($con,"SELECT Name from pricelist where test_id=$test_id")or die(mysqli_error());
while ($x = mysqli_fetch_array ($z)) {
$name=$x['Name'];
$query=mysqli_query($con,"SELECT result from result_details where result_id=$result_id")or die(mysqli_error());
while ($query1 = mysqli_fetch_array ($query)) {
$result=$query1['result'];
}
}
}
}
}
答案 0 :(得分:0)
只需添加:
HTTP(s)
GROUP BY将具有相同field1,field2,...和Charge的所有行分组在一起,然后HAVING COUNT(1)= 1仅显示只有1个祖先的行。我希望它能起作用