【发布时间】:2013-12-09 17:42:00
【问题描述】:
大家好,我有以下疑问:
update tblAnimal as p
join tblGrouping as tfs on tfs.tblGroupingId = p.tblGroupingId
join tblShelter as ses on ses.tblShelterId = tfs.tblShelterId
join tblFind as tf on ses.tblFindId = tf.tblFindId
set findColor = 'y'
where p.animalData like (select searchName from tblSearchCriteria where animalId = p.tblanimalId)
or p.history like (select searchName from tblSearchCriteria where animalId = p.tblanimalId);
所以我想这个查询只从子查询中返回一列是可以的,但是一旦您开始从该返回查询中返回多个值,我们就会开始遇到麻烦。
我的问题是,当预期从子查询返回多于一列时,实现上述目标的最佳方法是什么;本质上,我想要做的是处理与搜索条件表中一样多的 searchNames,并将 findcolor 更新为“y”,以匹配任何返回的搜索名称。
我希望这是可以理解的。
【问题讨论】:
-
在尝试 UPDATE 之前,看看您是否可以编写一个返回所需结果集的 SELECT。
-
searchName 是否包含诸如 % 之类的通配符?
-
没有,目前它只包含一个要搜索的字符串