1

I have a database table that looks like this:

<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>

I have a JPA query that I can't figure out. It currently looks like this:

select o.customer.id from ContactListMember o where o.contactList.id = 2 and o.contactList.id = 3

I know this isn't right. I'm trying to get it to return a single customerId when that customerId has a record with a contactList = 2 and it has a record with a contactList = 3. So in this case I need the query to return the customerId of 9 and not customerId 1.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.