0

我有两张桌子

id  documenttitle  committee  issuedate

和标签

documentid  tagname

用户只能访问他们是相关委员会成员的文件。所以我想运行一个查询,我可以在其中更改委员会、标签和文档,并让系统计算出结果。我的查询是这样的:

SELECT a.`id`,`documenttitle`,`committee`,`issuedate`, `tagname`
FROM `w4c_document_management_documents` AS a 
INNER JOIN `w4c_document_managment_tags` AS b 
ON a.id= b.documentid 
OR tagname = 'tag list' 
OR documenttitle LIKE 'doc%' 
WHERE a.issuedate >= '' 
GROUP BY `documenttitle` HAVING committee = 2 OR committee = 9 OR committee = 10 

只能它似乎不受标记名的限制。任何帮助都会很棒。

4

1 回答 1

0

可能看起来更像这样:

SELECT a.`id`, a.`documenttitle`, a.`committee`, a.`issuedate`, b.`tagname`
FROM `w4c_document_management_documents` AS a 
INNER JOIN `w4c_document_managment_tags` AS b 
ON a.id= b.documentid 
WHERE a.issuedate >= '' 
AND a.committee in (2,9,10)
AND (b.tagname = 'tag list' OR a.documenttitle LIKE 'doc%')

或者

SELECT a.`id`, a.`documenttitle`, a.`committee`, a.`issuedate`, b.`tagname`
FROM `w4c_document_management_documents` AS a 
INNER JOIN `w4c_document_managment_tags` AS b 
ON a.id= b.documentid AND b.tagname = 'tag list'
WHERE a.issuedate >= '' 
AND a.committee in (2,9,10)
AND a.documenttitle LIKE 'doc%'
于 2013-10-04T17:24:12.777 回答