IF RADIOGROUP1.ITEMINDEX = 4 THEN
BEGIN
QUERY1.CLOSE;
QUERY2.Close;
QUERY1.SQL.CLEAR;
QUERY2.SQL.Clear;
SSQL := FORMAT('SELECT DBPGM.PGMID, DBPGM.PGMTITLE FROM DBPGM, DBSUB WHERE DBPGM.PGMID = DBSUB.PGMID AND DBSUB.SUBPGM1 =''%S''', [TRIM(EDIT1.TEXT)]);
SSQL := FORMAT('SELECT DBPGM.PGMID, DBPGM.PGMTITLE FROM DBPGM, DBSUB WHERE DBPGM.PGMID = DBSUB.PGMID AND DBSUB.SUBPGM2 =''%S''', [TRIM(EDIT1.TEXT)]);
SSQL := FORMAT('SELECT DBPGM.PGMID, DBPGM.PGMTITLE FROM DBPGM, DBSUB WHERE DBPGM.PGMID = DBSUB.PGMID AND DBSUB.SUBPGM3 =''%S''', [TRIM(EDIT1.TEXT)]);
SSQL := FORMAT('SELECT DBPGM.PGMID, DBPGM.PGMTITLE FROM DBPGM, DBSUB WHERE DBPGM.PGMID = DBSUB.PGMID AND DBSUB.SUBPGM4 =''%S''', [TRIM(EDIT1.TEXT)]);
SSQL := FORMAT('SELECT DBPGM.PGMID, DBPGM.PGMTITLE FROM DBPGM, DBSUB WHERE DBPGM.PGMID = DBSUB.PGMID AND DBSUB.SUBPGM5 =''%S''', [TRIM(EDIT1.TEXT)]);
QUERY1.SQL.ADD(SSQL);
QUERY2.SQL.ADD(SSQL);
TRY
QUERY2.OPEN;
SHOWMESSAGE(SSQL);
STRINGGRID1.Cells[0,0] := '프로그램아이디';
STRINGGRID1.Cells[1,0] := '프로그램제목';
STRINGGRID1.CELLS[0,1]:=QUERY2.FIELDS[0].ASSTRING;
STRINGGRID1.CELLS[1,1]:=QUERY2.FIELDS[1].ASSTRING;
QUERY2.SQL.CLEAR;
EXCEPT
QUERY1.CLOSE;
Query2.Close;
APPLICATION.MESSAGEBOX('검색도중 에러발생', '에러', MB_OK+MB_ICONINFORMATION);
EXIT;
//Query1.FREE;
end;
QUERY1.CLOSE;
Query2.CLOSE;
END;
테이블이 두개이면 QUERY문두 두개를 사용해야하나여?
위 소스가 잘못 되었나좀 봐 주세요..
답변 기다립니다.
근데 SSQL을 저렇게 사용하면, 마지막에 넣은 쿼리문만 적용되겠죠..
그리고 format형식을 사용하는것 보다 Query1.Sql.Add 메소드와 ParamByName을 사용하시는게 훨신 편할거예요..
원하시는 결과가 뭔지를 모르겠습니다.??