그누보드 sql 쿼리 구문 문의
본문
그누보드에 사용되는 쿼리문인데요
이런식으로 작성이 되어 있습니다.
$sql = " select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' order by bf_no ";
이런식으로 되어 있는것도 있구요
sql_fetch는 데이터를 하나만 불러올때 쓰는 php 내장함수(?) 잘 모르겠네요
$board=sql_fetch("select * from $g4[board_table] where bo_table='$bo_table'");
여튼 잘 모르겠는데
제가 2개의 테이블을 조인해서 리스트를 만들건데 도무지 조인을 하면 에러가 발생해서 문제를 해결하지 못하고
있습니다.
제가 구현하고자하는 것은
$board=mysql_query("select g4_write_profile.wr_subject, g4_write_result.wr_id,g4_write_result.wr_num,g4_write_result.wr_subject,g4_write_result.ca_name,g4_write_result.wr_1 from g4_write_profile left join g4_write_result on g4_write_profile.wr_id = g4_write_result.ca_name");
우선 profile 테이블과 result테이블을 조인해서 profile의 subject와 result의 ca_name가 같은 값을 찾아
result 테이블에서 id, nume, subject, ca_name, wr_1필드를 뽑아서 리스트로 뿌려주려고 합니다.
위와 같이 구문을 작성하는것이 맞는지요..~~
고수분들의 도움 부탁드립니다.
답변 3
$board=sql_fetch("select a.wr_subject, b.wr_id,b.wr_num,b.wr_subject,b.ca_name,b.wr_1 from a.g4_write_profile left join b.g4_write_result on b.wr_id = b.wr_id");
이런식으로 해보세요
에러메시지도 같이 올려주세요.
왠지 아래 문제 일것 같은데요.
$board=mysql_query("select g4_write_profile.wr_subject, g4_write_result.g4_write_profile.wr_id,g4_write_result.wr_num,g4_write_result.wr_subject,g4_write_result.ca_name,g4_write_result.wr_1 from g4_write_profile left join g4_write_result on g4_write_profile.wr_id = g4_write_result.ca_name");
에러 메시지 입니다.
my sql 서버의 버전이 문제인지 아니면, 버전에 맞지 않는 구문이 문제인지 모르겠습니다.
select * from g4_write_result where wr_is_comment = 0 order by wr_num, wr_reply limit 0,
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 '' at line 1error file : /bbs/board.php