gpt4 book ai didi

php - SQL查询优化转换

转载 作者:行者123 更新时间:2023-11-29 22:02:23 25 4
gpt4 key购买 nike

我尝试优化(转换)此 SQL 查询

SELECT DISTINCT c.id, c.couponid, c.branchid, c.chainid
FROM `users_roles` a, `field_data_field_ypefthinos` b, `custom_redemptions` c, `field_data_field_chain_manager` e, `field_data_field_node_tax_inception` f, `field_data_field_brand_manager` j, `field_data_field_brand_node_ref` k, `field_data_field_product_ref` i, `field_data_field_company_manager` z, `field_data_field_brand_company` t
WHERE
(a.rid = 4
AND a.uid = ?
AND b.field_ypefthinos_uid = a.uid
AND b.entity_id = c.branchid)

至:

SELECT DISTINCT c.id, c.couponid, c.branchid, c.chainid
FROM `custom_redemptions` AS c
INNER JOIN `field_data_field_ypefthinos` as b
ON b.entity_id = c.branchid
INNER JOIN `users_roles` as A
ON b.field_ypefthinos_uid = a.uid
WHERE a.rid 4 AND a.uid 351

但是它给了我语法错误

对于原始问题,请查看 SQL Query optimization - exec time

最佳答案

您忘记=登录WHERE子句:

 SELECT DISTINCT c.id, c.couponid, c.branchid, c.chainid
FROM `custom_redemptions` AS c
INNER JOIN `field_data_field_ypefthinos` as b
ON b.entity_id = c.branchid
INNER JOIN `users_roles` as A
ON b.field_ypefthinos_uid = a.uid
WHERE a.rid = 4 AND a.uid = 351

希望这有帮助。

关于php - SQL查询优化转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32498726/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com