我有一个如下所示的数据库表:
<style type="text/css">
table.tableizer-table {
border: 1px solid #CCC; font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
.tableizer-table td {
padding: 4px;
margin: 3px;
border: 1px solid #ccc;
}
.tableizer-table th {
background-color: #104E8B;
color: #FFF;
font-weight: bold;
}
</style><table class="tableizer-table">
<tr class="tableizer-firstrow"><th>id</th><th>contactList</th><th>customer</th></tr>
<tr><td>1</td><td>2</td><td>9</td></tr>
<tr><td>2</td><td>3</td><td>9</td></tr>
<tr><td>3</td><td>2</td><td>1</td></tr>
</table>
&#13;
我有一个我无法弄清楚的JPA查询。它目前看起来像这样:
select o.customer.id from ContactListMember o where o.contactList.id = 2 and o.contactList.id = 3
我知道这不对。当customerId有一个带有contactList = 2的记录并且它有一个带有contactList = 3的记录时,我试图让它返回单个customerId。所以在这种情况下我需要查询返回customerId为9而不是customerId 1。