테이블 2개를 선택해서 select를 하려고 합니다.
두 테이블은 연결되는 것은 없고, 그저 컬럼 형식만 같습니다
그래서 union을 써서 쿼리문을 출력했는데
원하는 결과는 나오지만 너무 느린거 같아서요ㅠㅠ
좋은 방법이 없을까요?
$sql_search = "and wr_name!='admin' ";
$sql_order = "order by wr_hit desc limit 0, $rows";
$tmp_write_table1 = $g4['write_prefix'] . $bo_table1;
$tmp_write_table2 = $g4['write_prefix'] . $bo_table2;
$sql = "select * from $tmp_write_table1 where wr_is_comment = 0 $sql_search union select * from $tmp_write_table2 where wr_is_comment = 0 $sql_search $sql_order";
이렇게 사용하였습니다.ㅠㅠㅠ
또 하나 문제가 발생하는게
이렇게 만들어진 결과값을 누르면(게시물을 누르면)
update set wr_hit = wr_hit + 1 where wr_id = '51478'
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 'set wr_hit = wr_hit + 1 where wr_id = '51478'' at line 1
error file : /gb4/bbs/board.php
이런 에러가 뜹니다.
아무래도 union을 사용해서 그런거 같은데 이것도 해결할 방안이 없을까요
답변 2개
답변을 작성하려면 로그인이 필요합니다.