【发布时间】:2013-03-12 16:34:57
【问题描述】:
我需要检查每个 entryForm 行的名称,并检查该名称是否出现在 .siteid 和 entryForm.siteid 匹配的 SiteContacts 列表中。 (没有必要检查站点不匹配的 entryForm 行。)我需要留下不匹配的 entryForms。
一个entryForm有一个siteContact,一个siteContact可以有多个entryForms。
select * from siteContacts, entryForm
where siteContacts.siteid=entryForm.siteid
and entryForm.name not like concat('%',siteContacts.lastname, '%')
siteContacts 是这样的表:
id | lastname | siteid
===============================
7 | Cooper | 2
8 | Hofstadter | 2
9 | Wolowitz | 3
10 | Koothrappali | 3
entryForms 是这样的表格:
id | name | siteid
==================================
1 | Sheldon Cooper | 2
2 | L. Hofstadter | 2
3 | Penny | 3
4 | Wolowitz | 3
5 | Dr Hofstadter | 2
结果应该是 Penny :
3 | Penny | 3
但事实并非如此......
【问题讨论】: