我想比较两个数据,如果数据彼此相同,请写下数据名称
如何更好的查询?
例如:
ExampleTable1 * ID = 5 --
| (5=5) ---> "Hello This Five" (vtname)
ExampleTable2 * BEID = 5 --
SQL:
$sql1 = "SELECT * FROM ExampleTable1 WHERE paid= ".$paidsi;
$result1 = mysqli_query($conn, $sql1);
if (mysqli_num_rows($result1) > 0) {
while($row1 = mysqli_fetch_assoc($result1)) {
$sql2 = "SELECT * FROM ExampleTable2";
$result2 = $conn->query($sql2);
if ($result2->num_rows > 0) {
while($row2 = $result2->fetch_assoc()) {
if ($row2["id"] == $row1["beid"]) {
echo $row2["vtname"];
} else {
echo "";
}
}
} else {
echo "0 results";
}
}
} else {
echo "0 results";
}
答案 0 :(得分:1)
使用list of possible causes why a bean method is not invoked when pressing h:commandButton
name
使用此查询,您将只获得实际需要的数据,因此数据库服务器和脚本之间移动的数据更少,操作它的代码更少