我想获取People和地址的所有列,其中CategoryId等于类别。sql查询连接多个表
有此查询。
SELECT
Category.Id, People.*, Adress.*
FROM
Category
JOIN
People ON People.CategoryId = Category.CategoryId
JOIN
Adress ON Adress.PeopleId = People.Id
WHERE
Category.CategoryId = @category
ORDER BY
People.PeopleId DESC ;
当我运行我的应用程序时出现错误。
Server Error in '/' Application.
Invalid column name 'Id'. Invalid column name 'Id'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Invalid column name 'Id'. Invalid column name 'Id'.
Source Error: Line 153: da.SelectCommand = command; Line 154: DataTable dt = new DataTable(); Line 155:
da.Fill(dt); Line 156: cn.Close(); Line 157:
PagedDataSource pgitems = new PagedDataSource();
为什么它不起作用?一些帮助 ?
使用visual studio本地数据库。
什么是不工作?它在语法上是不正确的吗?你会得到意想不到的结果?请说明 – andrewdleach
运行时会发生什么? –
哪种RDBMS适用于?请添加一个标签来指定您是使用'mysql','postgresql','sql-server','oracle'还是'db2' - 或者其他的东西。 –