2 Replies - 243 Views - Last Post: 23 March 2017 - 09:40 AM

#1 longr59  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 52
  • Joined: 20-September 07

Not unique table/alias error

Posted 23 March 2017 - 08:29 AM

When I run the below query I get the following error "Error Code: 1066. Not unique table/alias: 'invItemMaster'" I am not sure why

SELECT invItemMaster.itemNumber AS Item_Number, invItemMaster.description AS Description, posInvoiceDetail.orderQuantity AS Quantity FROM ((abcs.invItemMaster INNER JOIN abcs.invItemMaster ON invBarCode.itemId = invItemMaster.itemId) INNER JOIN abcs.invItemMaster ON posInvoiceDetail.itemId = invItemMaster.itemId) where invItemMaster.itemNumber = '5272378' or '5251834'


Is This A Good Question/Topic? 0
  • +

Replies To: Not unique table/alias error

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 4123
  • View blog
  • Posts: 13,011
  • Joined: 08-June 10

Re: Not unique table/alias error

Posted 23 March 2017 - 08:34 AM

I'd say because of abcs.invItemMaster. not sure if the query spans two databases or not, but it would explain things.
Was This Post Helpful? 0
  • +
  • -

#3 longr59  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 52
  • Joined: 20-September 07

Re: Not unique table/alias error

Posted 23 March 2017 - 09:40 AM

I figured it out I swapped the tables in my inner joins and got it working.

SELECT invItemMaster.itemNumber AS Item_Number, invItemMaster.description AS Description, posInvoiceDetail.orderQuantity AS Quantity FROM ((invItemMaster INNER JOIN invBarCode ON invBarCode.itemId = invItemMaster.itemId) INNER JOIN posInvoiceDetail ON posInvoiceDetail.itemId = invItemMaster.itemId) where invItemMaster.itemNumber = '5272378' or '5251834'

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1