-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()+"'";

我想smonth,sdatesyear合并成一个日期。

4

1 回答 1

1

DateSerial 可用于从组成部分创建单个日期 -
http://www.techonthenet.com/access/functions/date/dateserial.php

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

顺便说一句,通过允许将用户输入直接添加到 SQL 查询中,您有一个 SQL 注入漏洞。

于 2013-03-11T15:35:56.930 回答