姜太辣 2024-08-25 11:48 采纳率: 0%
浏览 12

sql报错1064,望解答!

一段sql代码报错:

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE>
        and aac.is_delete != 1 
        and aac.is_down != 1
        <if test="type != n' at line 6


我实在是看不出哪里有问题,只知道是在 where 里面出的问题,望解答!


SELECT
aa.*
FROM
`ap_article` aa
LEFT JOIN `ap_article_config` aac ON aa.id = aac.article_id
<WHERE>
        and aac.is_delete != 1 
        and aac.is_down != 1
        <if test="type != null and type == 1">
                and aa.publish_time <![CDATA[<]]> '2020-09-07 14:56:18'
        </if>
        <if test="type != null and type == 2">
                and aa.publish_time <![CDATA[>]]> '2021-04-19 00:08:05'
        </if>
        <if test="dto.tag != '__all__'">
                and aa.channel_id = 1
        </if>
</WHERE>
order by aa.publish_time desc
limit 10
  • 写回答

2条回答 默认 最新

  • 心寒丶 优质创作者: 编程框架技术领域 2024-08-27 08:57
    关注

    where后边怎么能直接接and呢,第一个and去掉 where xxx and xxx

    评论

报告相同问题?

问题事件

  • 创建了问题 8月25日