Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

SQL help required.

Thread Tools
 
Search this Thread
 
Old Sep 7, 2006 | 11:29 AM
  #1  
Bal's Avatar
Bal
Thread Starter
Scooby Regular
 
Joined: Jun 2000
Posts: 271
Likes: 0
Default SQL help required.

Hi chaps,

I have the following SQL query (SQL 2005).
Its basically retrieving some values using simple joins.
However there appears to be a problem with the LEFT OUTER JOIN:
"LEFT OUTER JOIN DDDispatchedOrder ON (OrderLineItemTransaction.OrderLineItemTransaction ID = DDDispatchedOrder.OrderItemTransactionID)
"
When I try to compile the code i Get :
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "OrderLineItemTransaction.OrderLineItemTransaction ID" could not be bound.

Any help would be appreciated.

Cheers
Bal

SELECT
ord.orderDate,
cc.forename + ' ' + cc.surname person,
prod.description,
oli.noofitems,
deladdr.housenameno + ' ' + deladdr.addressLine1 + ' ' + deladdr.addressLine2 + ' ' + deladdr.city + ' ' + deladdr.postcode + ' ' + deladdr.county + ' ' + deladdr.country deladdress
FROM
product prod,
OrderLineItem oli,
[Order] ord,
OrderTransaction ordT,
OrderLineItemTransaction oliT,
CustomerContact cc,
Customer cust,
DDDispatchedOrder dd,
address deladdr,
address invaddr
LEFT OUTER JOIN DDDispatchedOrder ON (OrderLineItemTransaction.OrderLineItemTransaction ID = DDDispatchedOrder.OrderItemTransactionID)
WHERE
prod.productID = oli.productID
AND ord.orderID = oli.orderID
AND ord.orderID = ordT.orderID
AND oliT.orderlineitemID = oli.orderlineitemID
AND cc.customercontactID = ord.customercontactID
AND cc.customerID = cust.customerID
AND ord.invoiceaddressID = invaddr.addressID
AND ord.deliveryaddressID = deladdr.addressID
AND ordT.dispatchTypeID = 2
Reply
Old Sep 7, 2006 | 11:53 AM
  #2  
DemonDave's Avatar
DemonDave
Scooby Regular
iTrader: (13)
 
Joined: Jan 2001
Posts: 4,997
Likes: 0
From: Midlands - between notts and derby !
Default

it looks like you have got a space or a funny char in the column indentifier

(OrderLineItemTransaction.OrderLineItemTransaction ID =
Reply
Old Sep 7, 2006 | 12:17 PM
  #3  
Hanley's Avatar
Hanley
Scooby Regular
 
Joined: May 2002
Posts: 3,229
Likes: 0
From: Liverpool
Default

Deffo looks like it's the space causing the problem
Reply
Old Sep 7, 2006 | 12:58 PM
  #4  
RichB's Avatar
RichB
Scooby Regular
 
Joined: Apr 1999
Posts: 3,666
Likes: 0
From: Bore Knee Muff
Default

normally you can say select * from somelongtablename a left join someotherlongtablename2 b on a.id=b.id so in effect you are trying to create an 'alias' of OrderLineItemTransaction.OrderLineItemTransaction and name it ID....
So my vote is also that the spaces are doing it - Use '_' instead of space
Or something like that...
Reply
Old Sep 7, 2006 | 06:53 PM
  #5  
EP82's Avatar
EP82
Scooby Regular
 
Joined: Feb 2005
Posts: 333
Likes: 0
Default

I'd say space too, hope you lay your syntax out better than that.

Makes it a hell of alot easier for figuring out why it wont work
Reply
Old Sep 7, 2006 | 07:36 PM
  #6  
AllenJ's Avatar
AllenJ
Scooby Regular
 
Joined: Mar 2004
Posts: 752
Likes: 0
Default

However there appears to be a problem with the LEFT OUTER JOIN:
"LEFT OUTER JOIN DDDispatchedOrder ON (OrderLineItemTransaction.OrderLineItemTransaction ID = DDDispatchedOrder.OrderItemTransactionID)
I guess your question has been answered.

Remove the space between Transaction and ID.
Reply
Old Sep 7, 2006 | 11:22 PM
  #7  
jpor's Avatar
jpor
Scooby Regular
iTrader: (1)
 
Joined: Sep 2003
Posts: 3,109
Likes: 0
Default

Can you not put " " at the start and end of the field you want to join? Or set that field up with an alias name in you're SELECT.
Reply
Old Sep 8, 2006 | 02:59 AM
  #8  
Dracoro's Avatar
Dracoro
Scooby Regular
 
Joined: Sep 2001
Posts: 10,261
Likes: 0
From: A powerslide near you
Default

If SQLServer then you could use the following syntax: [OrderLineItemTransaction ID]
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Frizzle-Dee
Essex Subaru Owners Club
13
Mar 9, 2019 07:35 PM
gazzawrx
Non Car Related Items For sale
13
Oct 17, 2015 06:51 PM
oilman
Trader Announcements
15
Oct 1, 2015 11:55 AM
oilman
Trader Announcements
0
Sep 23, 2015 12:35 PM




All times are GMT +1. The time now is 10:10 AM.