`

Column 'status' in where clause is ambiguous

阅读更多

当你需要联表查询时,若两个表都有相同的字段是,需要为相同字段加上表别名
例如:相同字段:status ==》t.status 即可解决。
该异常出现的原因筛选联表查询,由于status直接封装到查询的实体中从而引发异常。可以让status前面添加表名重新拼装sql进行联表查询
异常如下:
org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL [
select count(*) from (
    select info0_.id as id49_, info0_.infotype as infotype49_, info0_.title as title49_, info0_.subTitle as subTitle49_, info0_.content as content49_,
    info0_.type as type49_, info0_.createtime as createtime49_, info0_.publishtime as publisht8_49_, info0_.lastupdatetime as lastupda9_49_,
    info0_.views as views49_, info0_.lastViewTime as lastVie11_49_, info0_.remark as remark49_, info0_.icon as icon49_, info0_.summary as summary49_,
    info0_.source as source49_, info0_.ispoint as ispoint49_, info0_.important as important49_, info0_.support as support49_, info0_.oppose as oppose49_,
    info0_.status as status49_, info0_.sort as sort49_, info0_.sign as sign49_, info0_.keywords as keywords49_, info0_.iconintroduce as iconint24_49_,
    info0_.layouttype as layouttype49_, info0_.isreview as isreview49_, info0_.resourcestype as resourc27_49_, info0_.temp1 as temp28_49_,
    info0_.temp3 as temp29_49_, info0_.temp2 as temp30_49_, info0_.USERID as USERID49_, info0_.MEMBERID as MEMBERID49_ from T_INFO info0_,
    T_INFOANDCLASS infoandcla1_
    where info0_.id=infoandcla1_.infoid and infoandcla1_.classid=4 and status=? and resourcestype=? and (content like ?) and infotype=? and (source like ?) )  as a]
    ; Column 'status' in where clause is ambiguous;
    nested exception is com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Column 'status' in where clause is ambiguous

分享到:
评论

相关推荐

    MySQL异常:[Err] 1055 – Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nona…

    在MySQL中,错误提示 "[Err] 1055 – Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column…” 指的是在执行包含`GROUP BY`子句的查询时,你试图对未在`GROUP BY`子句中...

    Dynamic-WHERE-Clause

    在SQL编程中,"Dynamic-WHERE-Clause"是一个关键概念,特别是在处理复杂的查询需求时。它涉及到动态构建SQL语句的WHERE子句,使得查询条件可以根据不同的业务需求灵活变化。这通常在我们无法预知所有可能的查询条件...

    mysql中You can’t specify target table for update in FROM clause错误解决方法

    在MySQL数据库中,"You can’t specify target table for update in FROM clause"是一个常见的错误提示,意味着在同一个SQL语句中,你不能直接在一个`UPDATE`或`DELETE`语句的`FROM`子句中引用你想要更新或删除的表...

    MySQL5.7更改密码时出现ERROR 1054 (42S22)的解决方法

    新安装的MySQL5.7,登录时提示密码错误...in ‘field list’,原来是mysql数据库下已经没有password这个字段了,password字段改成了authentication_string 所以更改语句替换为update mysql.user set authentication_st

    unidac 7.4.11 pro for RAD Studio 10.3

    Bug with SQL statements containing a CONTAINS predicate in the WHERE clause is fixed Bug with application freezing when executing a stored procedure is fixed Bug with editing the ConnectString ...

    Devart UniDAC 7.4.11 Professional for RAD Studio 10.3 Rio

    Bug with SQL statements containing a CONTAINS predicate in the WHERE clause is fixed Bug with application freezing when executing a stored procedure is fixed Bug with editing the ConnectString ...

    UnidacPro8.0.1Rio.rar

    v8.0.1 RAD Studio 10.3 Rio is supported Support of UPPER and LOWER functions ...in the WHERE clause is fixed Bug with application freezing when executing a stored procedure is fixed Bug with editing the ...

    mysql中You can’t specify target table for update in FROM clause错误解决方法.docx

    ### MySQL中“You can’t specify target table for update in FROM clause”错误解决方法 在MySQL数据库管理过程中,遇到SQL语法错误是家常便饭,其中一种较为常见的错误是“You can’t specify target table for ...

    UnidacProv8.0.1Tokyo.rar

    v8.0.1 RAD Studio 10.2 Tokyo is supported Support of UPPER and LOWER ...in the WHERE clause is fixed Bug with application freezing when executing a stored procedure is fixed Bug with editing the ...

    mysql遇到Expression.docx

    在MySQL中,当你尝试执行一个包含`GROUP BY`子句的查询时,可能会遇到"Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column"这样的错误。这个错误提示表明你的查询违反了`...

    Hibernate几个常见错误解决方式

    错误信息:`Column 'df' in where clause is ambiguous` 这个错误表示在SQL查询中的`df`字段无法明确它属于哪个表。在联接查询中,当多个表都有相同的字段名时,需要明确指定表名来避免歧义。例如,应将`df<>1`...

    mysql中错误:1093-You can’t specify target table for update in FROM clause的解决方法

    在MySQL中,错误1093 - "You can't specify target table for update in FROM clause" 是一个常见的问题,它发生在尝试在`UPDATE`语句的`FROM`子句中直接引用要更新的同一张表时。这个错误表示MySQL不支持在`UPDATE`...

    微软内部资料-SQL性能优化5

    Normally, only the columns in the WHERE clause are helpful in determining useful indexes, but for a covering index, all columns must be included. If all columns needed for the query are in the index,...

    MySQL报错1093 – You can’t specify target table ‘t’ for update in FROM clause, Time: 0

    在MySQL数据库中,错误代码1093 - "You can’t specify target table ‘t’ for update in FROM clause" 是一个常见的错误,它通常发生在尝试在一个`UPDATE`语句的`FROM`子句中直接引用要更新的目标表时。...

    SSD7 选择题。Multiple-Choice

    (c) typing a syntactically correct SQL query that uses column and table names similar to the correct column and table names in a database (d) writing an English description of the data that the user...

    Clause_37_Auto-Negotiation.pdf

    《Clause 37 自协商原理详解》 在现代网络通信技术中,自协商(Auto-Negotiation)是一项关键功能,特别是在千兆以太网(Gigabit Ethernet, GE)环境中。Clause 37 自协商机制是IEEE 802.3标准的一部分,它允许网络...

    test-db-in-clause

    WHERE column_name IN (value1, value2, ..., valueN); ``` 在这个结构中,`column_name`是你想根据其值筛选的列,`value1, value2, ..., valueN`是一系列可能的值。例如,如果你想找出所有来自城市"北京"、"上海...

    MySQL5.7中的sql_mode默认值带来的坑及解决方法

    在正常项目开发过程中,如果MySQL版本从5.6升级到5.7版本。作为DBA在考虑数据库版本升级带来的影响时,一般会有几个注意点...ERROR 1055 (42000): Expression #3 of XXXXXX list is not in GROUP BY clause and contain

Global site tag (gtag.js) - Google Analytics