You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SQL:
SELECT Moment.*, User.*, Comment.* FROM apijson_demo.Moment AS Moment LEFT JOIN ( SELECT * FROM apijson_demo.apijson_user WHERE ( (name REGEXP BINARY 't') ) ) AS User ON User.id = Moment.userId LEFT JOIN ( SELECT * FROM apijson_demo.Comment ) AS Comment ON Comment.momentId = Moment.id LIMIT 10 OFFSET 0
SQL:
SELECT Moment.*, User.*, Comment.* FROM apijson_demo.Moment AS Moment LEFT JOIN ( SELECT * FROM apijson_demo.apijson_user WHERE ( (name REGEXP BINARY 't') ) ) AS User ON User.id = Moment.userId LEFT JOIN ( SELECT * FROM apijson_demo.Comment ) AS Comment ON Comment.momentId = Moment.id LIMIT 10 OFFSET 0
如果移到外层就不支持副表带条件了。
这个不会影响性能,像
LEFT JOIN ( SELECT*FROM`apijson_demo`.`Comment` ) AS`Comment`
Activity
TommyLemon commentedon Jul 8, 2019
JOIN 和 子查询 见 3.2 功能符
https://github.com/APIJSON/APIJSON/blob/master/Document.md#3.2
目前还不支持 UNION ALL,可以用主副表条件 OR 连接的 INNER JOIN 替代("join": "/ViceTable/refKey@")
也可以在建议收集箱加一个新增功能的建议
#37
gsqatm commentedon May 6, 2020
LEFT JOIN中,除了主表,其他表为何要先建立临时表?
例如:
{
"[]": {
"join": "</User/id@,</Comment/momentId@",
"Moment": {},
"User": {
"name~": "t",
"id@": "/Moment/userId"
},
"Comment": {
"momentId@": "/Moment/id"
}
},
"@Explain": true
}
SQL:
SELECT
Moment.*,User.*,Comment.* FROMapijson_demo.MomentASMomentLEFT JOIN ( SELECT * FROMapijson_demo.apijson_userWHERE ( (nameREGEXP BINARY 't') ) ) ASUserONUser.id=Moment.userIdLEFT JOIN ( SELECT * FROMapijson_demo.Comment) ASCommentONComment.momentId=Moment.idLIMIT 10 OFFSET 0TommyLemon commentedon Dec 17, 2020
如果移到外层就不支持副表带条件了。
这个不会影响性能,像
这种简单的子查询,MySQL 5.7+ 会自动优化为
见以上两条 SQL 下的两张 EXPLAIN 效果图,执行过程一样