Logo
Subquery

Subquery #

Principle #

DBPlusEngine supports partial subqueries when both the subquery and the enclosing query specify a slice key and the value of the slice key can be routed to the same slice.

SELECT * FROM (SELECT * FROM t_order WHERE order_id = 1) o WHERE o.order_id = 1;

In addition, DBPlusEngine can support subqueries for paging.

SELECT * FROM (SELECT row_.*, rownum rownum_ FROM (SELECT * FROM t_order) row_ WHERE rownum <= ?) WHERE rownum > ?;

Note: For cases where the condition is not met, ShardingSphere can execute but the result is incorrect.