사용자 ID가 세션 ID와 같지 않은 테이블에서 모든 레코드를 검색하는 데 문제가 있고 열 X의 값이 열의 값보다 큰 경우 Y. 결과를 되 돌리고 싶습니다. 내 코드 지금까지 ISwhere 연산자를 사용하여 모든 값 가져 오기
...
// Select all users that arent the current session users and have a
// higher integer in bank column than that of the credits column
$stmt = $conn->prepare('SELECT * FROM users WHERE user_id!=? AND user_bank <= user_credits');
$stmt->bindParam(1, $uid, PDO::PARAM_INT);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
// Return all records in a loop
어떻게 이러한 목표를 달성 할 수 있습니까?
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
print_r($row);
}
그것은 간주됩니다 좋은 연습 테이블에서 알려진 열을 선택하려면 :
오류 로그는
[Wed May 29 21:08:49 2013] [error] [client 89.240.62.228] PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''19497918' AND user_bank <= user_credits' at line 1' in ...
왜 'NOT'을 사용하지 마십시오 – samayo
뭐가 잘못 되었나요? –
현재 @PhilCross의 500 서버 오류가 발생하며 NOT 연산자를 알지 못합니다. 제안 해 주셔서 감사합니다 – Liam