Sign up ×
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. It's 100% free, no registration required.

I have four tables user, shops, offer, merchant in that id is unique and present in all table

id  shops
1    shop1
1    shop2
1    shop3
id   name
1    abc
id   date      business
1   2012-6-6    Mall
id   status
1    true
1    true
1    false

First select id from shop table then match with user to get username, then match with merchant table to get date, business.

Then match with shop table to get shops (count the shops that how much that id have), then match with offer table to get status (count the status=true that how much that id have)

share|improve this question
Is this homework? – a_horse_with_no_name Jun 28 '12 at 5:38
So firstly, you must create parent-child relationships between your tables. I suspect that a merchant may have one or more shops and more than one offer per shop. So, you may wish to start with merchant and create a column of shop ids in the merchant table. Then, create a one-to-many relationship between shops, offers, and users. Your example can be improved further; however, we need to start somewhere, no? – ooutwire Jun 28 '12 at 6:15
Please clarify your final objective. Type a sample result for example. – NoChance Jun 28 '12 at 6:47
name shops offer business date ---------------------------------------- abc 3 2 mall 2012-6-6 – giri Jun 28 '12 at 6:59
What have you tried? This isn't the "write code for you because you are too lazy to try" site. – HLGEM Jun 28 '12 at 16:50

Your Answer


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

Browse other questions tagged or ask your own question.