Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two tables: product & offers.

products has (prod_id, category_id, prod_name, brand, price, status)
offers has (offer_id, prod_id, offer_type, discount_amt, validity)

I want to display products on a page, 20 products at a time.

The problem that I want to display all the products from the offers table arranged by descending offer_id and then display products from the products table except those in the offers table within that 20 limit.

How can I achieve that?

share|improve this question
up vote 0 down vote accepted

Seems pretty straightforward.

SELECT * from products left join offers on prod_id=prod_id
ORDER BY offer_id DESC LIMIT 20;

See it here:!2/dff49/3/0

share|improve this answer
thanks for your help ers81239.. I solved my problem – Anusha Sep 18 '12 at 8:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.