SELECT w.well_id,
w.WELL_NR,
w.WELL_NM,
w.WELL_API_NR,
ws.WELL_SGMNT_SIDE_TRCK_CD,
wc.WELL_CMPLTN_CD,
wc.WELL_SGMNT_ID,
wc.WELL_CMPLTN_ID
FROM WELL W
JOIN WELL_SGMNT ws
ON ws.well_id=w.well_id
JOIN WELL_CMPLTN wc
ON ws.WELL_SGMNT_ID=wc.WELL_SGMNT_ID
WHERE w.well_id ='13030';
此查询的结果如下,但我想选择WELL_CMPLTN_ID的最大值。
答案 0 :(得分:0)
试试这个
<?php
$con = mysqli_connect("localhost", "root", "password", "databasename");
$username = $_POST["username"];
$statement = mysqli_prepare($con, "SELECT * FROM user WHERE username = ?");
mysqli_stmt_bind_param($statement, "s", $username);
mysqli_stmt_execute($statement);
mysqli_stmt_store_result($statement);
mysqli_stmt_bind_result($statement, $user_id, $username);
$response["success"] = false;
while(mysqli_stmt_fetch($statement)){
$response["success"] = true;
$response["username"] = $username;
echo json_encode($response);
?>
答案 1 :(得分:0)
你可以试试这个:
SELECT * FROM(
SELECT w.well_id,
w.WELL_NR,
w.WELL_NM,
w.WELL_API_NR,
ws.WELL_SGMNT_SIDE_TRCK_CD,
wc.WELL_CMPLTN_CD,
wc.WELL_SGMNT_ID,
wc.WELL_CMPLTN_ID
FROM WELL W
JOIN WELL_SGMNT ws
ON ws.well_id=w.well_id
JOIN WELL_CMPLTN wc
ON ws.WELL_SGMNT_ID=wc.WELL_SGMNT_ID
WHERE w.well_id ='13030
ORDER BY wc.WELL_CMPLTN_CD DESC
)
WHERE ROWNUM = 1;
我希望它有所帮助!