서로 다른 게시판에서 데이타 불러오기 문의
본문
현재 하나의 게시판을 불러오는 쿼리를 사용하고 있습니다.
여기에서 A의 게시판의 "A" 라는 이름(ca_name)필드와 B라는 게시판의 "A"라는 이름(ca_name)필드의
데이타를 한 페이지에 보여주고 싶은데 제가 초보라 쉽지가 않습니다.
어떤 방법이 없을까요
현재는 리스트 전체를 가져와서 카테고리의 이름을 클릭하여 해당하는 사람의 리스트를 볼수 있습니다.
이것을 A라는 게시판의 홍길동 페이지에 들어가면 B라는 게시판의 리스트에서 홍길동에 해당되는 필드만
가져와서 리스트로 뿌려주려고 합니다.
아래는 B게시판의 전체 리스트인데요 이것을 위에 내용처럼 구현하려고 하는데 도움 부탁드립니다.
감사합니다.
<?
echo "<hr>";
$bo_table='B';
$write_table=$g4[write_prefix].$bo_table;
$board=sql_fetch("select * from $g4[board_table] where bo_table='$bo_table'");
$board_skin_path = "{$g4['path']}/skin/board/{$board['bo_skin']}";
include "list.php";
//include "list.php";
?>
답변 3
select * from tableA a
left join tableB b on b.column = a.column
이렇게 하면 되요.
join에 대해 찾아보시면 많이 나와요.
$bo_table='result';
include "list.php";
$board=sql_fetch("select * from $g4[board_table] where bo_table='$bo_table'");
$board_skin_path = "{$g4['path']}/skin/board/{$board['bo_skin']}";
include "list.php";
이렇게 작성이 되어 있는데
이것을 서로다른 테이블끼리 조인을 하면
$write_table=$g4[write_prefix].$bo_table;
include "list.php";
$board=sql_fetch("select * from result,profile where result.wr_subject = profile.ca_name");
$board_skin_path = "{$g4['path']}/skin/board/{$board['bo_skin']}";
include "list.php";
result 테이블의 wr_subject 필드와 profile의 ca_mame 필드를 조인을 하려고 하는데
어렵네요...
구문 작성이 힘든데 도움 부탁 드립니다.