如果其中至少有一个与MYSQL中的regexp匹配,则返回一个布尔值

时间:2017-03-22 13:26:23

标签: mysql regex where

我有一个名为fileName的键,其值为org.eclipse.jgit / src / org / eclipse / jgit / internal / ketch / ProposalRound.java,如果fileName与%/ src%匹配,我想返回一个布尔值。查询看起来像

SELECT p.id, p_userName,
COUNT(f.id) as NoOfFilesModified, 
sum(f.f_linesInserted) as linesInserted, 
sum(f.f_linesDeleted) as linesDeleted
FROM t_change as c, t_file as f, t_revision as r, t_people as p
WHERE f.f_revisionId = r.id 
AND r.rev_changeId = c.id
AND c.ch_authorAccountId = p.id
GROUP BY p.id, p.p_userName;

结果以

获得
id  p_userName  NoOfFilesModified   linesInserted   linesDeleted
1   spearce     2190                   50102    20117
2   HudsonVoter 397 14272   494

我想添加另一个字段,如果至少有一个文件与%/ src /%匹配,则返回1或0

提前致谢!

1 个答案:

答案 0 :(得分:0)

尝试使用子查询,如

$set = ['online_time' => "(online_time + $t)"];
$where = 'ID = '. $id;
$this->db->update('users', $set, $where);

EXISTS(SELECT 1 FROM t_file WHERE f.f_revisionId = r.id AND f.filename REGEXP 'src')