2013-03-11 29 views
-1

如何在此查詢中連接?將單獨的字段連接到日期

SQL

SELECT 
    eventscheduling.eventID, 
    event.eventName, 
    event.description, 
    sponsorCLUB.Organization, 
    department.Dname, 
    eventscheduling.smonth, 
    eventscheduling.sdate, 
    eventscheduling.syear, 
    eventscheduling.tHour, 
    eventscheduling.tMinute, 
    eventscheduling.tAmPm, 
    eventscheduling.venue, 
    eventscheduling.representative 
FROM eventscheduling, event, department, sponsorCLUB 
WHERE event.eventID=eventscheduling.eventID and 
    sponsorCLUB.sponsorID=eventscheduling.sponsorID and 
    department.DeptID=sponsorCLUB.DeptID and 
    eventscheduling.eventID='"+txtsearch.getText()+"'"; 

代碼

String sql="select eventscheduling.eventID, event.eventName, event.description, 
sponsorCLUB.Organization, department.Dname, eventscheduling.smonth, eventscheduling.sdate, 
eventscheduling.syear, eventscheduling.tHour, eventscheduling.tMinute, eventscheduling.tAmPm, 
eventscheduling.venue, eventscheduling.representative from eventscheduling, event, department, 
sponsorCLUB where event.eventID=eventscheduling.eventID and 
sponsorCLUB.sponsorID=eventscheduling.sponsorID and department.DeptID=sponsorCLUB.DeptID and 
eventscheduling.eventID='"+txtsearch.getText()+"'"; 

我想smonthsdatesyear組合成一個日期。

+0

你如何看待結果以及你的數據庫是什麼? – pn8830 2013-03-11 15:22:55

+0

設置此變量的編程語言是什麼? – 2013-03-11 15:32:08

回答

1

DateSerial可以被用來創建從構成部件的單個日期 -
http://www.techonthenet.com/access/functions/date/dateserial.php

SELECT 
    DateSerial(eventscheduling.syear, 
      eventscheduling.smonth, 
      eventscheduling.sdate) as eventschedulingdate 

BTW你必須通過允許直接添加到SQL查詢用戶輸入的SQL注入漏洞。

相關問題