1、ORDER BY 排序
ORDER BY
SELECT * FROM (
(SELECT e.FID,e.FName,e.FUpdateTime,e.FIssuedStatus,e.FBackgroundImg,u.FRealName FUserName FROM T_CC_ExerciseSet e JOIN t_um_user u ON e.FOwnedUserID = u.FID WHERE FOwnedUserID = 1 )
UNION ALL
(SELECT e.FID,e.FName,e.FUpdateTime,e.FIssuedStatus,e.FBackgroundImg,u.FRealName FUserName FROM T_CC_ExerciseSet e JOIN T_CC_ExerciseSet_BuyList b ON e.FID = b.FExerciseSetID JOIN t_um_user u ON b.FBuyUserID = u.FID WHERE b.FBuyUserID = 1 )
) t ORDER BY t.FUpdateTime DESC limit 0,10
2、WHERE + LIKE 模糊查询
WHERE + LIKE
SELECT * FROM (
(SELECT e.FID,e.FName,e.FOwnedUserID,e.FUpdateTime,e.FIssuedStatus,e.FBackgroundImg,e.FIntro,e.FClassificationCode,u.FRealName FROM T_CC_ExerciseSet e
JOIN T_UM_User u on u.FID = e.FOwnedUserID WHERE FOwnedUserID = 1 )
UNION ALL
(SELECT e.FID,e.FName,e.FOwnedUserID,e.FUpdateTime,e.FIssuedStatus,e.FBackgroundImg,e.FIntro,e.FClassificationCode,u.FRealName FROM T_CC_ExerciseSet e
JOIN T_UM_User u on u.FID = e.FOwnedUserID JOIN T_CC_ExerciseSet_BuyList b ON e.FID = b.FExerciseSetID WHERE b.FBuyUserID = 1 )
) t WHERE FClassificationCode LIKE 'TB_2_2_01%' and FName LIKE '%语文%' ORDER BY t.FUpdateTime DESC limit 0,10
网友评论