Unknown column 'ROWNUM' in 'where clause' 解决方案

I read a lot of topics about this problem but most of them were having problem with some complex (at least for me) code; I have followed the oracle ROWNUM Pseudocolumn guide but when I write

SELECT * FROM " + tableName + "
WHERE ROWNUM < 12;

I get this error:

Unknown column 'ROWNUM' in 'where clause'

I then tried to do like the solution suggested here Select where row number = rownum but nothing changes.

My code looks like this:

sql = "SELECT C.* "
    + "FROM ( SELECT * "
    + "       FROM " + tableName + " ) C "
    + "WHERE C.ROWNUM < 12;";
resultSet = statement.executeQuery(sql);

 

Best How To : 

You can refer http://www.w3schools.com/sql/sql_top.asp.

ROWNUM is used in Oracle. Assuming you are using MySQL as you have tagged your question to MySQL.

You can change ROWNUM with limit clause

SELECT * FROM " + tableName + "
LIMIT 11;
上一篇:搭建源仓库之nexus


下一篇:JMeter JMeter远程分布式联机性能测试