0

The tables are client, promo, and coupons

client can have multiple promo and promo will have several coupons.coupon_codes and will have coupons.copon_status.

Now I want to perform a delete on a client but I want to check first that there are is no unused coupons.coupon_code on a promo based on the coupons.copon_status which would be 0 for unused and 1 for used.

I don't know how to make mysql table here so i have to write my question.

Cœur
  • 37,241
  • 25
  • 195
  • 267
alisongaleon
  • 153
  • 2
  • 4
  • 13
  • Can you edit your post with your tables structure. Would it be lot easier to help you. It seems that you need a `delete` statement with a `not in` in your `where` clause – Jorge Campos Nov 13 '13 at 04:01
  • You should look into Foreign Keys to handle the automatic deletion of relationships that exist between clients, promos and coupons. – maiorano84 Nov 13 '13 at 04:06
  • yeah i would love to make a table structure but how? lurker problem, sorry. – alisongaleon Nov 13 '13 at 04:07
  • If it is that you do not know how to create a MySQL database and it's tables ... use a tool like phpmysql or MySQL workbench or the mysql commandline tool. You can find out how to use them via web search. Once you have a database, you just use the respective approach to create your tables (i.e., table_client and fields clientId, clientName ..., table_promo and fields promoId, clientId, ..., table_coupons and fields couponId, promoId (and or clientId), coupon_codes, coupon_status ... – nocturns2 Nov 13 '13 at 04:53
  • @nocturns2 no, i mean i don't know how to create a table here in stackoverflow to show my table. – alisongaleon Nov 14 '13 at 02:12
  • here's a pretty simple example of illustrating a table from the following post http://stackoverflow.com/questions/190296/how-do-you-effectively-model-inheritance-in-a-database – nocturns2 Nov 21 '13 at 21:36

0 Answers0