Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When I run this query in SQL Server Management Studio it works fine, but when I try to populate a grid in VB.net it gives me the following error

"could refer to more than one table listed in the FROM clause of your SQL statement"

Below is the query:

SQL
SELECT Distinct T1.QID, T1.Title, T1.Vendorid, T1.Severity, T1.Published, Total
FROM Missing_Patch_Table T1,
(
    SELECT QID, COUNT (IP) as Total
    FROM Missing_Patch_Table
    Group by QID
) as T2
where T1.QID = T2.QID
Order by Total desc, Severity, QID;



can someone please help me on this
Posted
Comments
Peter Leow 16-Jan-15 7:53am    
Would you mind showing your sql statement inside VB.NET? Use the "Improve question" widget.

1 solution

It means one of the fields where you haven't specified the table name exists in both tables. It could be Total, Severity, or QID. Just put T1. or T2. in front of each field, even in the ORDER BY clause and that should fix the error.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900