gpt4 book ai didi

mysql - 我怎样才能整理这个 MySQL 代码并使其更具可读性?

转载 作者:行者123 更新时间:2023-11-29 04:12:54 25 4
gpt4 key购买 nike

SELECT
*
FROM
`table_1`
WHERE
`id` =
(
SELECT
`an_id`
FROM
`table_2`
WHERE
`id` =
(
SELECT
`another_id`
FROM
`table_3`
WHERE
`id` =
(
SELECT
`yet_another_id`
FROM
`table_4`
WHERE
`id` = 123
)
)
)

很丑吧?
我想我可以在这里使用 JOIN - 但如何使用?

最佳答案

select t1.*
from
table1 t1,
table2 t2,
table3 t3,
table4 t4
where
t4.id = 123
and t3.id = t4.yet_another_id
and t2.id = t3.another_id
and t1.id = an_id;

关于mysql - 我怎样才能整理这个 MySQL 代码并使其更具可读性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5568781/

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