일단 쿼리를 해보고 없을 경우 다시 receptionold 에서 찾는 수 밖에 없을 것 같습니다. 아니면 만약 둘중하나에서 존재한다면 그냥 한꺼번에 두군데서 찾는 방법도 있을 것 같군요.
[ 1 의 방법 ]
:: $number = $cgi/>param('number');
:: if (length($number) == 6)
:: {
:: $cmd = qq! select * from reception where receptionno like '%$number' !;
:: }else{
:: $cmd = qq! select * from reception where receptionno='$number' !;
::
:: }
위의 구문을 이렇게 해야 할 것 같습니다.
$number = $cgi/>param('number');
if (length($number) == 6)
{
$cmd = qq! select * from reception where receptionno like '%$number' !;
}else{
$cmd = qq! select * from reception where receptionno='$number' !;
}
$result = $Pg/>query($cmd);
if (!$result) {
if (length($number) == 6)
{
$cmd = qq! select * from receptionold where receptionno like '%$number' !;
}else{
$cmd = qq! select * from receptionold where receptionno='$number' !;
}
}
$result = $Pg/>query($cmd);
이런식으로 하면 해결되지 않을까요.
[ 2의 방법 ]
:: $number = $cgi/>param('number');
:: if (length($number) == 6)
:: {
:: $cmd = qq! select * from reception where receptionno like '%$number' !;
:: }else{
:: $cmd = qq! select * from reception where receptionno='$number' !;
::
:: }
위의 구문을 다음과 같이 바꾸면 되지 않을까 싶습니다.
$number = $cgi/>param('number');
if (length($number) == 6)
{
$cmd = qq! select * from reception where receptionno like '%$number'
union
select * from receptionold where receptionno like '%$number' !;
}else{
$cmd = qq! select * from reception where receptionno = '%$number'
union
select * from receptionold where receptionno = '$number' !;
}
물론 두번째 구문은 그 결과값이 굳이 reception 에 있는지 receptionold 에 있는것인지 알필요가 없을 경우에 가능한 방법입니다. 참조하시기 바랍니다.
>>이준영 님께서 쓰시길<<
:: 안녕하세요
:: 저는 서비스센터에서 서버를 관리하는 사람인데요...
:: 전에 근무하시던 분이 하나의 테이블을 두개로 나눠 놓았습니다.
:: 하나는 reception 이고 다른 하나는 receptionold 거든요 문제는
:: 사용자에게 "접수번호"를 입력 받아서 테이블을 검색할때
:: reception테이블만 검색을 한다는 것입니다.
:: 먼저 reception에서 검색을 하고 없으면 receptionold에서 검색하는
:: 방법은 없을까여? 제발 도와주세요 아래쿼리문을 어떻게 고치면 될까요....
:: (참고로 perl로 작성된 프로그램입니다.)
::
:: $number = $cgi/>param('number');
:: if (length($number) == 6)
:: {
:: $cmd = qq! select * from reception where receptionno like '%$number' !;
:: }else{
:: $cmd = qq! select * from reception where receptionno='$number' !;
::
:: }
|