[英]SQL table names with spaces
I have a table name with spaces between say like 'Orders Details'.我有一个表名,中间有空格,比如“订单详细信息”。
I want to use that table in stored procedures with joins.I have tried using alias names,[],`` in queries but nothing seems to be working.Can anybody help me on this error!我想在带有连接的存储过程中使用该表。我尝试在查询中使用别名,[],`` 但似乎没有任何效果。有人可以帮我解决这个错误!
Do not use order
as a column alias.不要使用
order
作为列别名。 It is a SQL keyword.它是一个 SQL 关键字。 I would just use
o
:我只会使用
o
:
select o.*, od.*
from orders o join
order_details od
on o.orderid = od.orderid
where year(o.orderdate) = @orderyear;
Notes:笔记:
JOIN
condition is on ProductId
.JOIN
条件在ProductId
上。 However, that is highly suspicious.ProductId
doesn't belong in Orders
(usually) if there is a detail table.ProductId
不属于Orders
(通常)。orderdate
does not seem to be defined, because it has a red underline. orderdate
似乎没有定义,因为它有一个红色下划线。select *
.select *
。 For one thing, you will have duplicate column names.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.