Tricky Query
Posted: Wed Jul 06, 2005 2:29 pm
Code: Select all
$sql = 'SELECT *, COUNT(DISTINCT(REQUEST.TROUTD)) as `num`
FROM REQUEST
INNER JOIN RESPONSE ON REQUEST.INTRN_SEQ_NUM = RESPONSE.INTRN_SEQ_NUM
WHERE REQUEST.CLIENT_ID = \''.$_SESSION['client_id'].'\' AND RESPONSE.RESULT_CODE = 5 `num` = \'1\'
ORDER BY ';WHERE REQUEST.CLIENT_ID = \''.$_SESSION['client_id'].'\' AND RESPONSE.RESULT_CODE = 5 `num` = \'1\'
ORDER BY ';
Okay first I know your thinking 2 things, the query has more stuff to it, and there is not GROUP BY yet, which is party of my question. My problem is that I only want to select rows where there is no duplication of TROUTD, so if the same TROUTD appears in more than 1 row, exclude all rows with that TROUTD. Secondly, for some reason I am still getting 'Unknown column `num`' error, which I don't understand why. Excuse my arrogance but I've been coding for much too long the past coupl]
Okay first I know your thinking 2 things, the query has more stuff to it, and there is not GROUP BY yet, which is party of my question. My problem is that I only want to select rows where there is no duplication of TROUTD, so if the same TROUTD appears in more than 1 row, exclude all rows with thSEQ_NUM = RESPONSE.INTRN_SEQ_NUM
WHERE REQUEST.CLIENT_ID = \''.$_SESSION['client_id'].'\' AND RESPONSE.RESULT_CODE = 5 `num` = \'1\'
ORDER BY ';
Okay first I know your thinking 2 things, the query has more stuff to it, and there is not GROUP BY yet, which is party of my question. My problem is that I only want to select rows where thereEST.TROUTD)) as `num`
FROM REQUEST
INNER JOIN RESPONSE ON REQUEST.INTRN_SEQ_NUM = RESPONSE.INTRN_SEQ_NUM
WHERE REQUEST.CLIENT_ID = \''.$_SESSION['client_id'].'\' AND RESPONSE.RESULT_CODE = 5 `num` = \'1\'
ORDER BY ';
Okay first I know your thinking 2 things, the query has more stuff to it, and there is not GROUP BY yet, which is party of my question. My problem is that I only want to select rows where there is no duplication of TROUTD, so if the same TROUTD appears in more than 1 row, exclude all rows with that$sql = 'SELECT *, COUNT(DISTINCT(REQUEST.TROUTD)) as `num`
FROM REQUEST
INNER JOIN RESPONSE ON REQUEST.INTRN_SEQ_NUM = RESPONSE.INTRN_SEQ_NUM
WHERE REQUEST.CLIENT_ID = \''.$_SESSION['client_id'].'\' AND RESPONSE.RESULT_CODE = 5 `num` = \'1\'
ORDER BY ';
Okay first I know your thinking 2 things, the query has more stuff to it, and there is not GROUP BY yet, which is party of my question. My problem is that I only want to select rows where there is no duplication of TROUTD, so if the same TROUTD appears in more than 1 row, exclude all rows with that TROUTD. Secondly, for some reason I am still getting 'Unknown column `num`' error, which I don't understand why. Excuse my arrogance but I've been coding for much too long the past couple days. My attempt at getting `num` was to only make it find rows that have been counted as 1, meaning there is only 1 instance.