我使用以下查询来查找来自医学部门的客户:
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'
在表中,可能性是“医学院”和“医学系”;但是,不会返回任何记录。我错过了什么?
谢谢。
答案 0 :(得分:2)
Access中的通配符是*不是%
像这样改变你的sql:
like '*medicine'
答案 1 :(得分:0)
我认为你可能并不总是有一个事件,所以你需要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'