Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with View

Status
Not open for further replies.
Mar 17, 2005
147
US
I have to create a view that uses 3 tables

Orders:
OrderDetails:
Users:

The orders table has a one to many relationship with the ordersdetails tables as such:

orders 'OrderReferenceID'
&
orderdetails 'DetailOrderID'

And the users table has a one to many relationship with the orders table as such:

users 'UserID'
&
orders 'OrdersUserID'

I need to "SEE" all the orders placed by orderid and user.

Here are the fields I would require for the view.

Orders: OrderDetails:

OrderReferenceID(PK) DetailOrderID(FK)
OrderUserID DetailQuantity
OrderTotal
OrderDate
OrderStatus

Users:
UserID
FullName

Thanks
 
Did you try something like this?
Code:
create 		view OrderInformation
as
select 		o.orderreferenceID, 
		o.orderuserid, 
		o.ordertotal,
		o.orderdate,
		o.orderstatus,
		od.detailorderid,
		od.detailquantity,
		u.userid,
		u.fullname
from		orders o 
		inner join orderdetails od
		on (o.orderreferenceid = od.detailorderid)
		inner join users u
		on (o.orderuserid = u.userid)
order by	o.orderreferenceid,
		u.userid

Regards,
AA
 
Hey thanks for your help on this. btw.

I got the following error messages at this line
.
Microsoft ODBC Microsoft Access Driver Syntax error in query expression (o.oderreferenceid = od.detailorderid)
inner join users us
on (o.orderuserid = u.userid)
 
Well, the query was designed for sql server.

It think you should post it in the access forum.

Also try removing the '(' braces in the on clause.

something like this:
Code:
on o.oderreferenceid = od.detailorderid
inner join users u
on o.orderuserid = u.userid

Regards,
AA
 
maybe you need to add an AS clause for the table aliases.

something like this
from orders as o ...

Regards,
AA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top