HQL查询不同的列

时间:2013-10-29 09:44:13

标签: mysql sql hql

我正在查询我的表机场名称为'term%'的行,并按名称排序。它看起来像这样,它工作正常:

from Airport where name like 'term%' order by name

现在我想在同一个查询中的列城市中查找“term%”,但我无法让它工作。 我想有类似的东西,但这不对:

 from Airport where name like 'term%' or where city like 'term%' order by named

2 个答案:

答案 0 :(得分:1)

您应该只有一个where

from Airport where name like 'term%' or city like 'term%' order by name

答案 1 :(得分:0)

查询应该是

from Airport where name like 'term%' or city like 'term%' order by name  

而不是

from Airport where name like 'term%' or where city like 'term%' order by named  

仅使用一个where子句及其name而非named