sql_query() 구한 값 합치는 방법이 있을까요?

· 2013-03-06 (수) 14:45:40 · 1665 · 3
$out_hos_re_26 = sql_query("select * from g4_write_membership where (wr_1 between '00000000' and '$to_date') AND wr_26 = $to_date");
$out_hos_re_30 = sql_query("select * from g4_write_membership where (wr_1 between '00000000' and '$to_date') AND wr_30 = $to_date");
$out_hos_re_33 = sql_query("select * from g4_write_membership where (wr_1 between '00000000' and '$to_date') AND wr_33 = $to_date");


3개의 쿼리문으로 구한 데이터를 하나로 합치려고 아래 처럼 했는데 안되네요..

$result = array($out_hos_re_26 + $out_hos_re_30 + $out_hos_re_33);

for ($i=0; $row=sql_fetch_array($result); $i++) {

echo $row[wr_subject];
}


array 말고 join , array_merge 사용해도 안되네요...

방법이 있을까요???
|

댓글 3개

2013-03-06 (수) 14:55:51
해결했습니다 ㅡㅡ;;; 왜~ 왜~ 질답란에 질문을 하고 구글신께 문의드리면 답을 주시는지... 모르겠습니다.

union 또는 union all 로 처리하면 되는군요...



$out_hos_re_26 = sql_query("select * from g4_write_membership where (wr_1 between '00000000' and '$to_date') AND wr_26 = $to_date
union all
select * from g4_write_membership where (wr_1 between '00000000' and '$to_date') AND wr_30 = $to_date
union all
select * from g4_write_membership where (wr_1 between '00000000' and '$to_date') AND wr_33 = $to_date");

이리하면 되는군요 ,....^^;;;
$out_hos_re_tot = sql_query("select * from g4_write_membership where (wr_1 between '00000000' and '$to_date') AND (wr_26 = $to_date OR wr_30 = $to_date OR wr_33 = $to_date)");
2013-03-06 (수) 17:44:16
감사합니다 루트님...^^ 전 각각 행들에서 값을 뽑아내야 해서요.. 이렇게 한방에 하는 방법도 있지만 저리하면 제가 원하는 결과 값이 나오지가 않아서요..^^
댓글을 작성하시려면 로그인이 필요합니다.

그누4 질문답변

66,531건

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기 기존 게시물은 열람만 가능합니다.

+
제목 글쓴이 날짜 조회
13-03-06 조회 1,700
13-03-06 조회 1,110
13-03-06 조회 1,495
13-03-06 조회 1,666
13-03-06 조회 986
13-03-06 조회 1,032
13-03-06 조회 913
13-03-06 조회 884
13-03-06 조회 2,915
13-03-06 조회 1,620
13-03-06 조회 871
13-03-06 조회 562
13-03-06 조회 1,685
13-03-06 조회 744
13-03-06 조회 1,073
13-03-06 조회 1,264
13-03-06 조회 1,664
13-03-06 조회 1,615
13-03-06 조회 1,949
13-03-05 조회 2,125