根据您提供的表结构和实体类定义,可以使用以下SQL语句来实现根据assetList中的namecode模糊查询,并返回带有数据所在行的idList<AssetPageResp>

SELECT 
  a.id,
  a.code,
  a.unit_id AS unitId,
  a.unit_name AS unitName,
  a.asset_type_id AS assetTypeId,
  a.asset_type_name AS assetTypeName,
  a.nature,
  a.state,
  a.source,
  a.name,
  a.purchased_date AS purchasedDate,
  a.initial_value AS initialValue,
  a.quantity,
  a.measurement_unit AS measurementUnit,
  a.depreciation_value AS depreciationValue,
  a.residual_value AS residualValue,
  a.created_date AS createdDate,
  a.split_flag AS splitFlag,
  a.warrant_type AS warrantType,
  a.agent_unit_id AS agentUnitId,
  a.management_type AS managementType,
  a.parent_id AS parentId,
  a.building_area AS buildingArea
FROM (
  SELECT 
    al.id,
    al.code,
    al.unit_id,
    al.unit_name,
    al.asset_type_id,
    al.asset_type_name,
    al.nature,
    al.state,
    al.source,
    al.name,
    al.purchased_date,
    al.initial_value,
    al.quantity,
    al.measurement_unit,
    al.depreciation_value,
    al.residual_value,
    al.created_date,
    al.split_flag,
    al.warrant_type,
    al.agent_unit_id,
    al.management_type,
    al.parent_id,
    al.building_area,
    ROW_NUMBER() OVER (ORDER BY al.id) AS rn
  FROM asset_lease al
  WHERE JSON_CONTAINS(`asset_list`, 
    JSON_OBJECT('name', 'your_name', 'code', 'your_code'),
    '$[*]'
  ) = 1
) a
WHERE a.rn BETWEEN ? AND ?;

请将your_nameyour_code替换为实际的模糊查询条件。同时,将?替换为实际的分页参数,例如起始行号和结束行号

使用TiDB数据库CREATE TABLE asset_lease id bigint20 NOT NULL AUTO_INCREMENT COMMENT 主键 unit_id bigint20 NOT NULL COMMENT 承租申请单位id asset_type_id bigint20 DEFAULT NULL COMMENT 资产类型id asset_lease_guide_pr

原文地址: https://www.cveoy.top/t/topic/iEnw 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录