选择查询错误无效的对象名称 [英] Select Query error Invalid object name
问题描述
你好
我在数据库中有三个表
表1:产品
{
productId(主键)
productImage
}
Table2:ProductLoc //此表没有主键
{
culture_id
Productid外键
产品名称
}
表3:订单
{
orderid PrimaryKey
名称
手机
productid外键
}
我要选择此项目
名称,手机------------来自订单
产品名称------------来自ProductLoc
我尝试了此代码,但发生了错误
hello
I have three tables in data base
Table1 : Product
{
productId ( Primary Key )
productImage
}
Table2 :ProductLoc //This table don''t have primary key
{
culture_id
Productid foreignkey
ProductName
}
Table3 : Orders
{
orderid PrimaryKey
name
mobile
productid foreignkey
}
I want To select this item
Name,Mobile ------------From Orders
Product Name ------------From ProductLoc
I try this code but Error Occured
select Name,Mobile,ProductName
From Orders ,ProductLoc
Where Orders.id=ProductLoc.ProductId
消息208,第16级,状态1,第1行
无效的对象名称订单".
请帮助我
Msg 208, Level 16, State 1, Line 1
Invalid object name ''Orders''.
Please Help Me
推荐答案
这样的事情
从订单中选择名称,移动电话,产品名称加入Order.Productid上的ProductLoc = ProductLoc.productid"
让我知道是否可以.
how about like this
"Select Name,Mobile,ProductName From Orders Join ProductLoc on Orders.Productid=ProductLoc.productid"
Let me know whether it is ok or not.
这篇关于选择查询错误无效的对象名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!