1

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

shop
------
id  shops
1    shop1
1    shop2
1    shop3
user
-----
id   name
1    abc
merchant
---------
id   date      business
1   2012-6-6    Mall
offer
------
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)

5
  • 3
    Is this homework?
    – user1822
    Commented Jun 28, 2012 at 5:38
  • 2
    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
    Commented Jun 28, 2012 at 6:15
  • Please clarify your final objective. Type a sample result for example.
    – NoChance
    Commented Jun 28, 2012 at 6:47
  • name shops offer business date ---------------------------------------- abc 3 2 mall 2012-6-6
    – giri
    Commented Jun 28, 2012 at 6:59
  • 1
    What have you tried? This isn't the "write code for you because you are too lazy to try" site.
    – HLGEM
    Commented Jun 28, 2012 at 16:50

0

Your Answer

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