sql语句读取XML字段属性

/取节点PackageConditon和BrandConditon里的字段值

Conditions--------为根元素

/PackageCondition,BrandCondtion-----为节点

/auto_match----为字段属性

 

select
auto_match.value('(/Conditions/PackageCondition)[1]','nvarchar(max)') a,
auto_match.value('(/Conditions/BrandCondition)[1]','nvarchar(max)') b ,
article_group_id
from CMS_articlegroup
where auto_match is not null

在 MyBatisPlus 中,读取数据库中 datetime 类型的字段可以使用 Java 的 Date 类型来接收。在 SQL 语句中,可以使用 MyBatis 提供的 `#{}` 占位符来接收参数。在配置 SQL 语句的结果类型时,可以使用 MyBatis 提供的 `resultType` 属性或者 `resultMap` 属性进行配置。具体可以在 XML 文件中配置如下: 使用 `resultType` 属性配置结果类型: ```xml <select id="getUserByCreateTime" resultType="com.example.entity.User"> SELECT * FROM user WHERE create_time >= #{startTime,jdbcType=TIMESTAMP} AND create_time <= #{endTime,jdbcType=TIMESTAMP} </select> ``` 其中,`resultType` 属性指定了结果类型为 `com.example.entity.User`,该实体类中应该定义一个 `java.util.Date` 类型的字段来接收数据库中的 datetime 类型的字段。 使用 `resultMap` 属性配置结果类型: ```xml <select id="getUserByCreateTime" resultMap="resultMap"> SELECT * FROM user WHERE create_time >= #{startTime,jdbcType=TIMESTAMP} AND create_time <= #{endTime,jdbcType=TIMESTAMP} </select> <resultMap id="resultMap" type="com.example.entity.User"> <result column="create_time" property="createTime" jdbcType="TIMESTAMP" javaType="java.util.Date"/> </resultMap> ``` 其中,`resultMap` 属性指定了结果类型为 `resultMap`,该 resultMap 中配置了 `create_time` 字段映射到实体类中的 `createTime` 字段,类型为 `java.util.Date`。在对应的实体类中,该字段也应该使用 `java.util.Date` 类型来定义。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值