How can I remove unnecesary ( and ` in views?

Discussion of open issues, suggestions and bugs regarding database management and administration tools for MySQL
Post Reply
ralfh
Posts: 1
Joined: Mon 06 Jul 2009 09:54

How can I remove unnecesary ( and ` in views?

Post by ralfh » Wed 06 Oct 2021 22:06

How can I remove unnecesary ( and ` in views?

Example:

SELECT
`h`.`id` AS `id`,
`h`.`id` AS `customer_order_header_id`,
`c`.`id` AS `customer_id`,
`c`.`customer_no` AS `customer_no`,
`h`.`address1` AS `address1`,
`h`.`address2` AS `address2`,
`h`.`address3` AS `address3`,
`h`.`country_name` AS `country_name`,
`h`.`zip_code` AS `zip_code`,
`h`.`city` AS `city`,
`h`.`street` AS `street`,
`h`.`contact_person` AS `contact_person`,
`h`.`receipt_no` AS `receipt_no`,
`h`.`receipt_date` AS `receipt_date`,
`h`.`delivery_date` AS `delivery_date`,
`h`.`receipt_type` AS `receipt_type`,
(SELECT
COUNT(0) AS `total_position_count`
FROM `customer_order_detail` `od`
WHERE (`od`.`customer_order_header_id` = `h`.`id`)) AS `position_count`,
IFNULL(`sq`.`qty_header`, 0) AS `items_on_stock`,
(SELECT
COUNT(0) AS `expr1`
FROM `picklist_detail` `pd`
WHERE (`ph`.`id` = `pd`.`picklist_header_id`)) AS `pick_position_count`,
`h`.`total_gross_amount` AS `total_gross_amount`,
`h`.`total_net_amount` AS `total_net_amount`,
`h`.`total_rebate_amount` AS `total_rebate_amount`,
`h`.`total_vat_amount` AS `total_vat_amount`,
`cur`.`currency_name` AS `currency_name`,
`s`.`item_name` AS `order_state_name`,
`s`.`id` AS `order_state_id`,
`u`.`display_name` AS `user`,
`h`.`location_id` AS `location_id`,
`l`.`item_name` AS `location`,
`h`.`customer_order_no` AS `customer_order_no`,
`h`.`payment_type_id` AS `payment_type_id`,
`h`.`payment_type_name` AS `payment_type_name`,
`p1`.`description` AS `project_description`,
`ph`.`commission_id` AS `commission_id`,
`ph`.`id` AS `picklist_header_id`,
`ps`.`item_name` AS `picklist_state_name`
FROM ((((((((((`customer` `c`
JOIN `customer_order_header` `h`
ON ((`c`.`id` = `h`.`customer_id`)))
LEFT JOIN `customer_order_header_stock_qty` `sq`
ON ((`h`.`id` = `sq`.`customer_order_header_id`)))
JOIN `currency` `cur`
ON ((`h`.`currency_id` = `cur`.`id`)))
JOIN `order_state` `s`
ON ((`h`.`order_state_id` = `s`.`id`)))
JOIN `order_type` `ot`
ON ((`h`.`receipt_type` = `ot`.`id`)))
JOIN `view_application_user` `u`
ON ((`h`.`application_user_id` = `u`.`id`)))
LEFT JOIN `location` `l`
ON ((`h`.`location_id` = `l`.`id`)))
LEFT JOIN `project` `p1`
ON ((`h`.`project_id` = `p1`.`id`)))
LEFT JOIN `picklist_header` `ph`
ON (((`h`.`id` = `ph`.`order_header_id`)
AND `ph`.`picklist_state_id` IN (SELECT
`ps1`.`id`
FROM `picklist_state` `ps1`
WHERE (`ps1`.`is_open` = 1)))))
LEFT JOIN `picklist_state` `ps`
ON (((`ph`.`picklist_state_id` = `ps`.`id`)
AND (`ps`.`is_open` = 1))))
WHERE ((1 = 1)
AND (`ot`.`is_order` = 1)
AND ((`s`.`is_open` = 1)
OR (`s`.`is_sent` = 1)
OR (`s`.`is_partial_delivered` = 1)))

alexa

Re: How can I remove unnecesary ( and ` in views?

Post by alexa » Thu 07 Oct 2021 07:45

This is the setting of the MySQL server itself and is governed by the server variable sql_mode.

We would recommend you to refer to the MySQL manual or support on this.

Post Reply