내 테이블의 내부 조인 시나리오에 걸렸습니다. 저를 도와주세요? 내가 여기서 뭘 잘못하고 있니? 여기 MySQL 내부가 하나의 열에 두 개의 열을 결합합니다.
내가 할 노력하고있어 시나리오입니다 :내가 결제 및 배송 국가가가/I는 내부 조인 채워하려고 열을 주장하지만, 어떻게 든이 작동하지 않습니다. 도와 주셔서 대단히 감사합니다.
$sql = $this->connection->query("SELECT * FROM ".TBL_USERS."
INNER JOIN ".TBL_USER_LEVEL." ON ".TBL_USERS.".userlevel = ".TBL_USER_LEVEL.".user_level_id
INNER JOIN ".TBL_COUNTRIES." ON ".TBL_USERS.".country OR ".TBL_USERS.".bcountry = ".TBL_COUNTRIES.".country_id
INNER JOIN ".TBL_STATES." ON ".TBL_USERS.".states OR ".TBL_USERS.".bstates = ".TBL_STATES.".states_id
WHERE ".TBL_USERS.".username = '$username'");
나는 검색어를 (으)로 변경했습니다. 에러 메신저 뻥이
PHP 치명적인 오류는 다음과 같습니다 catch되지 않은 예외 'PDOException'메시지 'SQLSTATE [42000] : 구문 오류 또는 액세스 위반 : 1,066하지 독특한 테이블/별칭 :'국가 ''
$sql = $this->connection->query("SELECT * FROM ".TBL_USERS."
INNER JOIN ".TBL_USER_LEVEL." ON ".TBL_USERS.".userlevel = ".TBL_USER_LEVEL.".user_level_id
INNER JOIN ".TBL_COUNTRIES." ON ".TBL_USERS.".country = ".TBL_COUNTRIES.".country_id
INNER JOIN ".TBL_COUNTRIES." ON ".TBL_USERS.".bcountry = ".TBL_COUNTRIES.".country_id
INNER JOIN ".TBL_STATES." ON ".TBL_USERS.".states = ".TBL_STATES.".states_id
INNER JOIN ".TBL_STATES." ON ".TBL_USERS.".bstates = ".TBL_STATES.".states_id
WHERE ".TBL_USERS.".username = '$username'");
에서 참조
field
부울 타입의 경우를 제외하고 여기
확인, 올바른 구문의 감사에게 @ Tiberiu-누트 스탠
$sql = $this->connection->query("SELECT * FROM ".TBL_USERS."
LEFT JOIN ".TBL_COUNTRIES." ON ".TBL_USERS.".country = ".TBL_COUNTRIES.".country_id
LEFT JOIN ".TBL_COUNTRIES." AS ".TBL_COUNTRIES."_b ON ".TBL_USERS.".bcountry=".TBL_COUNTRIES."_b.country_id
INNER JOIN ".TBL_USER_LEVEL." ON ".TBL_USERS.".userlevel = ".TBL_USER_LEVEL.".user_level_id
LEFT JOIN ".TBL_STATES." ON ".TBL_USERS.".states = ".TBL_STATES.".states_id
LEFT JOIN ".TBL_STATES." AS ".TBL_STATES."_b ON ".TBL_USERS.".bstates=".TBL_STATES."_b.states_id
WHERE ".TBL_USERS.".username = '$username'");
정확히 작동하지 않는 것은 무엇입니까? –
SQL 오류가 발생합니까? 그렇다면 게시 할 수 있습니까? 처음에는 JOIN 절에서 OR을 사용할 수 있다고 생각하지 않습니다.별로 의미가 없습니다. MySQL 문서에서 어쨌든 볼 수 없습니다. – fred2