MS Access 2007查询返回无结果

时间:2021-03-25 15:38:01

I am using the following query to find client who are from the medicine department:

我使用以下查询来查找来自医学部门的客户:

SELECT client.clientID, client.firstname, client.lastname, client.organization,
       client.department, client.email, events.Date, events.title,
       eventAttendance.eventID, eventAttendance.clientID,
       eventAttendance.attended
FROM client INNER JOIN 
     (events INNER JOIN eventAttendance ON events.id = eventAttendance.ID) 
     ON client.clientID = eventAttendance.clientID
WHERE client.organization like '%medicine'

In the table, the possibilities are "School of Medicine" and "Department of Medicine;" however, no records are returned. What am I missing?

在表中,可能性是“医学院”和“医学系”;但是,不会返回任何记录。我错过了什么?

Thank you.

2 个解决方案

#1


2  

The wild card character in Access is a * not an %

Access中的外卡字符是*不是%

change your sql like so:

像这样改变你的sql:

like '*medicine'

#2


0  

I think it is likely that you do not always have an event, so you need LEFT JOIN:

我想你可能并不总是有一个事件,所以你需要LEFT JOIN:

SELECT client.clientID, client.firstname, client.lastname, client.organization,
       client.department, client.email, events.Date, events.title,
       eventAttendance.eventID, eventAttendance.clientID,
       eventAttendance.attended
FROM client LEFT JOIN 
     (events LEFT JOIN eventAttendance ON events.id = eventAttendance.ID) 
     ON client.clientID = eventAttendance.clientID
WHERE client.organization like '*medicine'

#1


2  

The wild card character in Access is a * not an %

Access中的外卡字符是*不是%

change your sql like so:

像这样改变你的sql:

like '*medicine'

#2


0  

I think it is likely that you do not always have an event, so you need LEFT JOIN:

我想你可能并不总是有一个事件,所以你需要LEFT JOIN:

SELECT client.clientID, client.firstname, client.lastname, client.organization,
       client.department, client.email, events.Date, events.title,
       eventAttendance.eventID, eventAttendance.clientID,
       eventAttendance.attended
FROM client LEFT JOIN 
     (events LEFT JOIN eventAttendance ON events.id = eventAttendance.ID) 
     ON client.clientID = eventAttendance.clientID
WHERE client.organization like '*medicine'