將SQL查詢出來的數(shù)據(jù)作為一個(gè)張“表",之后根據(jù)這張“表”在進(jìn)行條件查詢。
SQL語句演變一:
SELECT?tA.a_code,?tA.b_code,?tA.c_code,?tA.a_name,?tA.a_time,? ???tB.b_clazz,?tC.c_model,?tD.d_good FROM?TableA?tA LEFT?JOIN?TableB?tB?ON?tA.a_code?=?tB.a_code?? LEFT?JOIN?TableC?tC?ON?tA.b_code?=?tC.b_code ? LEFT?JOIN?TableD?tD?ON?tA.c_code?=?tD.c_code
SQL語句演變二:
SELECT?Tab.a_code,?Tab.b_code,?Tab.c_code,?Tab.a_name,?Tab.a_time,?Tab.b_clazz,?Tab.c_model,?Tab.d_good FROM (SELECT?tA.a_code,?tA.b_code,?tA.c_code,?tA.a_name,?tA.a_time,? ???tB.b_clazz,?tC.c_model,?tD.d_good FROM?TableA?tA LEFT?JOIN?TableB?tB?ON?tA.a_code?=?tB.a_code?? LEFT?JOIN?TableC?tC?ON?tA.b_code?=?tC.b_code ? LEFT?JOIN?TableD?tD?ON?tA.c_code?=?tD.c_code)?Tab
SQL語句演變?nèi)?br />
Mybatis中的動(dòng)態(tài)sql,條件查詢,模糊匹配。
SELECT?Tab.a_code,?Tab.b_code,?Tab.c_code,?Tab.a_name,?Tab.a_time,?Tab.b_clazz,?Tab.c_model,?Tab.d_good FROM (SELECT?tA.a_code,?tA.b_code,?tA.c_code,?tA.a_name,?tA.a_time,? ???tB.b_clazz,?tC.c_model,?tD.d_good FROM?TableA?tA LEFT?JOIN?TableB?tB?ON?tA.a_code?=?tB.a_code?? LEFT?JOIN?TableC?tC?ON?tA.b_code?=?tC.b_code ? LEFT?JOIN?TableD?tD?ON?tA.c_code?=?tD.c_code)?Tab Tab.a_code?LIKE?CONCAT('%',?#{a_code},?'%') AND?Tab.b_code?LIKE?CONCAT('%',?#{b_code},?'%') AND?Tab.c_model?LIKE?CONCAT('%',?#{c_model},?'%')