I've written a SQL statement where these specific columns are from a table and it joins with another table and the primary key, ReportID, serves as the link between the two tables. I am using NOT IN to accurately display the reports of a company, but I get no output when a company is selected. Is there anywhere in the query that I would have to rearrange?
valsql1 = "SELECT DISTINCT c.ReportID, c.COMPANYID, rl.REPORTNAME
FROM CompanyReportListTable c
right join ReportList rl on c.reportid = rl.ReportID
WHERE c.reportid NOT IN(Select rl.ReportID FROM ReportList rl)
and rl.ReportVisible = 1
and CompanyID = " & DropDownList1.SelectedValue