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 07 September 2006, 11:29 AM
  #1  
Bal
Scooby Regular
Thread Starter
 
Bal's Avatar
 
Join Date: Jun 2000
Posts: 271
Likes: 0
Received 0 Likes on 0 Posts
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
Old 07 September 2006, 11:53 AM
  #2  
DemonDave
Scooby Regular
iTrader: (13)
 
DemonDave's Avatar
 
Join Date: Jan 2001
Location: Midlands - between notts and derby !
Posts: 4,997
Likes: 0
Received 0 Likes on 0 Posts
Default

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

(OrderLineItemTransaction.OrderLineItemTransaction ID =
Old 07 September 2006, 12:17 PM
  #3  
Hanley
Scooby Regular
 
Hanley's Avatar
 
Join Date: May 2002
Location: Liverpool
Posts: 3,229
Likes: 0
Received 0 Likes on 0 Posts
Default

Deffo looks like it's the space causing the problem
Old 07 September 2006, 12:58 PM
  #4  
RichB
Scooby Regular
 
RichB's Avatar
 
Join Date: Apr 1999
Location: Bore Knee Muff
Posts: 3,666
Likes: 0
Received 0 Likes on 0 Posts
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...
Old 07 September 2006, 06:53 PM
  #5  
EP82
Scooby Regular
 
EP82's Avatar
 
Join Date: Feb 2005
Posts: 333
Likes: 0
Received 0 Likes on 0 Posts
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
Old 07 September 2006, 07:36 PM
  #6  
AllenJ
Scooby Regular
 
AllenJ's Avatar
 
Join Date: Mar 2004
Posts: 752
Likes: 0
Received 0 Likes on 0 Posts
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.
Old 07 September 2006, 11:22 PM
  #7  
jpor
Scooby Regular
iTrader: (1)
 
jpor's Avatar
 
Join Date: Sep 2003
Posts: 3,109
Likes: 0
Received 0 Likes on 0 Posts
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.
Old 08 September 2006, 02:59 AM
  #8  
Dracoro
Scooby Regular
 
Dracoro's Avatar
 
Join Date: Sep 2001
Location: A powerslide near you
Posts: 10,261
Likes: 0
Received 0 Likes on 0 Posts
Default

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



Quick Reply: SQL help required.



All times are GMT +1. The time now is 08:37 PM.