동일한 데이터베이스 (mySQL)에있는 2 개의 테이블에서 데이터를 검색하려고합니다. INNER JOIN을 사용하려고 시도했지만 SELECT 항목에 사용 된 WHERE가 두 테이블에서 동일하지 않다는 것을 깨달았습니다. 속성의 ID는 보고서의 ID와 동일하지 않으므로 두 번째 테이블에서 정확한 정보를 얻기 위해 쿼리에 지시 할 방법이 없습니다 (그게 맞다고 생각합니다)
어쨌든. 아래는 내 질문입니다. 누군가 내가이 작업을 제대로 수행하고 해당 필드를 모두 채우는 데 필요한 결과를 얻을 수있는 가장 좋은 방법을 알려주시겠습니까?
건배
<?php session_start();
header('Content-type: application/json');
require_once('DbConnector.php');
$connector = new DbConnector();
$customerid = '125';
$sql=( "SELECT DISTINCT reports.id, properties.title, reports.title, reports.date, reports.link FROM reports JOIN properties ON reports.visible = properties.customer WHERE properties.customer ='".$customerid."'" )or die( mysql_error("FAIL!!") );
$result = mysql_query($sql);
while($data = mysql_fetch_assoc($result)) {
$output[] = $data;
}
echo json_encode($output);
?>
이거 한번 해봐
<?php session_start();
header('Content-type: application/json');
require_once('DbConnector.php');
$connector = new DbConnector();
$customerid = '125';
$sql=( "SELECT DISTINCT reports.id, properties.title, reports.title, reports.date, reports.link FROM reports JOIN properties ON reports.visible = properties.visible WHERE properties.customer = '$customerid' " )or die( mysql_error("FAIL!!") );
$result = mysql_query($sql);
while($data = mysql_fetch_assoc($result)) {
$output[] = $data;
}
echo json_encode($output);
?>
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다