在mybatis中该sql语句有什么错误<select id="selectJourneyTempDetailListById" resultMap="JourneyTempDetailDtoResult"> select temp_day, GROUP_CONCAT(activity_id) activity_id, GROUP_CONCAT(address_type_cd) address_type_cd, GROUP_CONCAT(activity_type_cd) activity_type_cd, GROUP_CONCAT(presenter_type_cd) presenter_type_cd, from journey_temp_detail where temp_id = #{id} and is_del = '0' group by temp_day </select>
时间: 2024-03-02 08:52:16 浏览: 20
这个 SQL 语句中的错误是缺少了 `SELECT` 关键字。在 `from` 关键字前面应该加上需要查询的列名,比如 `SELECT temp_day, GROUP_CONCAT(activity_id) activity_id, ...`。修改后的 SQL 语句如下:
```xml
<select id="selectJourneyTempDetailListById" resultMap="JourneyTempDetailDtoResult">
SELECT
temp_day,
GROUP_CONCAT(activity_id) activity_id,
GROUP_CONCAT(address_type_cd) address_type_cd,
GROUP_CONCAT(activity_type_cd) activity_type_cd,
GROUP_CONCAT(presenter_type_cd) presenter_type_cd
FROM journey_temp_detail
WHERE temp_id = #{id} AND is_del = '0'
GROUP BY temp_day
</select>
```
注意,在 `WHERE` 子句中使用的参数 `id` 应该在 Java 代码中传入。
相关问题
mybatis plus 自定义xml查询 的 select 该如何写 <select id="selectByExpendTable" >
在 Mybatis-plus 中,自定义 XML 查询是通过在自定义的 Mapper 接口中定义方法来实现的。具体操作如下:
1. 在自定义的 Mapper 接口中添加方法声明,如下所示:
```
public interface CustomMapper<T> extends BaseMapper<T> {
List<T> selectByExpendTable(@Param("param1") String param1, @Param("param2") String param2);
}
```
2. 在 resources 目录下创建与 Mapper 接口相应的 mapper.xml 文件,添加自定义的 SQL 语句,如下所示:
```
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.mapper.CustomMapper">
<select id="selectByExpendTable" resultMap="BaseResultMap">
SELECT * FROM table_name WHERE column1 = #{param1} AND column2 = #{param2}
</select>
</mapper>
```
3. 在 application.yml 配置文件中加入自定义的 mapper.xml 文件路径,如下所示:
```
mybatis-plus:
mapper-locations:
- classpath*:mapper/*.xml
- classpath*:mapper/custom/*.xml
```
4. 在代码中调用自定义的方法,如下所示:
```
@Autowired
private CustomMapper customMapper;
public void test() {
List<T> list = customMapper.selectByExpendTable("value1", "value2");
}
```
这样就完成了自定义 XML 查询的实现。其中,selectByExpendTable 就是自定义的方法名,可以根据实际需要进行修改。
<select id="selectPPersonListById" parameterType="string" resultMap="PPersonListResult">
这看起来像是 MyBatis 的一个 SQL 映射文件中的一个 select 语句。其中,id 属性指定了这个 select 语句的唯一标识符,parameterType 属性指定了这个 select 语句的输入参数类型,resultMap 属性指定了这个 select 语句返回结果集的映射关系。具体的实现细节需要结合上下文来确定。