Skip to content

Query Result Export not using table aliases #14691

@imacarthur

Description

@imacarthur

Describe the bug

Original query:

select m.company, o.id, cd1.scheduled_date as pu_date, cd2.scheduled_date as del_date, o.total, p.name, a1.line1, a1.city, a1.postalcode, a2.line1, a2.city, a2.postalcode

from orders o, custom_delivery cd1, custom_delivery cd2, addresses a1, addresses a2, product p, order_lines ol, members m

where o.member_id=556 and cd1.order_id = o.id and cd1.service_type = 'P' and cd2.order_id = o.id and cd2.service_type='D' and a1.ownertype='order' and a1.ownerid=o.id and a2.ownertype='order' and a2.ownerid='order' and a1.addresstype=12 and a2.addresstype=13 and ol.order_id = o.id and ol.custom_package='S' and p.id = ol.product_id and m.id = o.member_id

query executes no errors. I want to export the results to a spreadsheet.

The results export, but the exported file is actually an html fragment with a server error:
#1066 - Not unique table/alias: 'custom_delivery'

In the error report is the actual query executed:

select members.company, orders.id, custom_delivery.scheduled_date as pu_date, custom_delivery.scheduled_date as del_date, orders.total, product.name, addresses.line1, addresses.city, addresses.postalcode, addresses.line1, addresses.city, addresses.postalcode 

FROM `orders`, `custom_delivery`, `custom_delivery`, `addresses`, `addresses`, `product`, `order_lines`, `members`

where orders.member_id=556 and custom_delivery.order_id = orders.id and custom_delivery.service_type = 'P' and custom_delivery.order_id = orders.id and custom_delivery.service_type='D' and addresses.ownertype='order' and addresses.ownerid=orders.id and addresses.ownertype='order' and addresses.ownerid='order' and addresses.addresstype=12 and addresses.addresstype=13 and order_lines.order_id = orders.id and order_lines.custom_package='S' and product.id = order_lines.product_id and members.id = orders.member_id

The table aliases are gone (custom_delivery cd1 was changed to custom_delivery)

Complete exported fragment attached.
members (1).zip

Server configuration

  • Operating system: Windows 10
  • Web server: apache 2.4
  • Database version: MariaDB 15.1
  • PHP version: 7.1
  • phpMyAdmin version: 4.7.7 & 4.8.2

Metadata

Metadata

Assignees

Labels

BugA problem or regression with an existing featureduplicatehas-prAn issue that has a pull request pending that may fix this issue. The pull request may be incomplete

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions