SuRa
SuRa

Reputation: 513

SQL query one-to-many

I need SQL query for the below scenario.

2 tables: price & product

price table has ManyToOne relationship with product(i.e., many prices were applicable to one product).

Now I need a query to get only the product details which available in price table.

Note: Using hibernate, I have specified in price as

@ManyToOne @JoinColumn(name = "PRODUCT_ID") private Product product;

But I don't specify OneToMany in product.

Upvotes: 2

Views: 461

Answers (1)

Bonifacio
Bonifacio

Reputation: 1502

In this case you can return the product attribute in your query, example:

select p.product from price p where p = :price

Hope this can help. :)

Upvotes: 1

Related Questions