sqlserver 多表关联多条件分页排序查询

川长思鸟来 2022-06-12 01:26 408阅读 0赞
  1. SELECT TOP
  2. (#{limit})
  3. storeId,
  4. intermediaryId,
  5. storeAddress,
  6. storeName,
  7. storePhone,
  8. principal,
  9. principalPhone,
  10. isEnable
  11. FROM
  12. (
  13. SELECT ROW_NUMBER() OVER (ORDER BY
  14. b.intermediaryId)
  15. AS RowNumber,
  16. storeId,
  17. intermediaryId,
  18. storeAddress,
  19. storeName,
  20. storePhone,
  21. principal,
  22. principalPhone,
  23. isEnable
  24. FROM
  25. (select
  26. uis.storeId,
  27. uis.intermediaryId,
  28. uis.storeAddress,
  29. uis.storePhone,
  30. uis.storeName,
  31. uis.principal,
  32. uis.principalPhone,
  33. uis.isEnable from user_inter_store uis inner join user_intermediary ui on uis.intermediaryId = ui.intermediaryId where uis.isEnable=1
  34. <if test=" name !=null and name !='' ">
  35. and ui.name = #{name}
  36. </if>
  37. <if test=" principal !=null and principal !='' ">
  38. and uis.principal =#{principal}
  39. </if>
  40. <if test=" storeAddress !=null and storeAddress !='' ">
  41. and uis.storeAddress =#{storeAddress}
  42. </if>
  43. <if test=" storeName !=null and storeName !='' ">
  44. and uis.storeName =#{storeName}
  45. </if>
  46. <if test=" principalPhone !=null and principalPhone !='' ">
  47. and uis.principalPhone like =#{principalPhone}
  48. </if>
  49. <if test="sort ==-1 ">
  50. order by uis.storeId desc
  51. </if>
  52. )
  53. as b
  54. ) as a
  55. WHERE (a.RowNumber >
  56. #{pages})

发表评论

表情:
评论列表 (有 0 条评论,408人围观)

还没有评论,来说两句吧...

相关阅读