我有一个查询,其中同时显示报告名称和报告 ID。这仅适用于预先检查报告的情况。这些值填充在数据网格中。如果未选中报告,则仅显示名称。我尝试使用 UPDATE 关键字,但一直遇到语法错误。我知道对查询的小更改很简单,但是当报告未选中或基本上 reportvisible 为 0 时,我在尝试显示 reportid 时遇到了困难。我如何解决此问题以显示 reportid,无论它是否是检查与否?
valsql1 = "SELECT c.ReportID, c.COMPANYID, rl.REPORTNAME
FROM CompanyReportListTable c
right join ReportList rl on c.reportid = rl.ReportID
and reportvisible = 1
and CompanyID =" & DropDownList1.SelectedValue & "
where rl.ReportID in (
Select ReportID
from ReportList
where ReportVisible = 1
)
order by ReportName"
最佳答案
您完全加入了reportvisible = 1,然后您专门选择了reportvisible = 1的reportID。您两次过滤了reportvisible = 0的行,所以您当然不会获取这些行的reportid。您应该将 rl.reportvisible
添加到 SELECT 子句,并从 join 和 where 子句中删除 reportvisible = 1
。
关于mysql - 选中未选中的值时更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38380090/