如何在此查询中连接?
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()+"'";
我希望smonth
,sdate
和syear
合并为一个日期。
答案 0 :(得分:1)
DateSerial可用于从组成部分创建单个日期 -
http://www.techonthenet.com/access/functions/date/dateserial.php
SELECT
DateSerial(eventscheduling.syear,
eventscheduling.smonth,
eventscheduling.sdate) as eventschedulingdate
通过允许将用户输入直接添加到SQL查询中,您有一个SQL注入漏洞。