나는 사용자가 날짜 조건을 추가 할 수있는 몇 가지 텍스트 상자를 가지고 다음 그는어떻게이 쿼리를 더 간단하게 만들 수 있습니까?
textbox1<year<textbox2 and textbox2<month<textbox3 and textbox4<day<textbox5 and textbox6<hour<textbox7 and textbox8<minute<textbox9
어떻게 간단한 쿼리를 만들 수있는 표는 (그 안에 IF-ELSE를 많이하지 않고) 도착?
QString request::date_search(QString type, int y1, int y2, int mon1, int mon2,
int d1, int d2, int h1, int h2, int min1, int min2)
{
QString req = "DATE("+type+") ";
QString temp;
if (((y1==0) && (mon1==0) && (d1==0) && (h1==0) && (min1==0)) &&
((y2==0) && (mon2==0) && (d2==0) && (h2==0) && (min2==0)))
{
return "";
}
if ((y1==0) && (mon1==0) && (d1==0) && (h1==0) && (min1==0))
{
return req += "= '" + temp.setNum(y2) + "-" + temp.setNum(mon2) + "-" +
temp.setNum(d2) + "-" + temp.setNum(h2) + "-" +
temp.setNum(min2) + "-" + "0'";
}
if ((y2==0) && (mon2==0) && (d2==0) && (h2==0) && (min2==0))
{
return req += "= '" + temp.setNum(y1) + "-" + temp.setNum(mon1) + "-" +
temp.setNum(d1) + "-" + temp.setNum(h1) + "-" +
temp.setNum(min1) + "-" + "0'";
}
req += "BETWEEN '" + temp.setNum(y2) + "-" + temp.setNum(mon2) + "-" +
temp.setNum(d2) + "-" + temp.setNum(h2) + "-" +
temp.setNum(min2) + "-" +"0' "
+ "AND" + "'" + temp.setNum(y1) + "-" + temp.setNum(mon1) + "-" +
temp.setNum(d1) + "-" + temp.setNum(h1) + "-" +
temp.setNum(min1) + "-" + "0'";
return req;
}
그것은 Y1 등은 텍스트 박스에서 파라미터 인 함수이다.
응용 프로그램 코드 언어는 무엇입니까? – davogotland
기존 쿼리를 게시 한 경우 도움이됩니다. –
C++의 쿼리입니다. –