Jump to content

Recommended Posts

I'm in a start-up and planing mode and come to a problem, that for me is should be a pretty basic thing but I can't find any solution at Google:

 

Profile table

ProfileID

Company name

 

Order table:

OrderID

ProfileId

OrderQuanity

OrderDesc

 

I want when a user make a order, that the orderID is based on the own auto_increment, so it's not based on all orders, just the own history of orders.

I first tired to set PRIMARY KEY to both OrderID and ProfileID in the order table, but that dosn't work togheter with having auto_increment on OrderID.

 

Data could be like this:

 

Profiles

1, BEACH STORE LTD

2, MUMY&PAPY Soho LTD

 

Order:

OrderID.....ProfileId....OrderDesc

1 ............. 1.............100 ice creams

2 ............. 1.............shorts

3 ............. 1.............hot shots

1 ............. 2............. pizza

2 ............. 2............. frozen margerita

3 ............. 2............. slush pumps

 

I want to know if this is possible to do this in the database structure and not in by coding. I'm using MySQL

It is possible in MyISAM tables: http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html

 

Although I'd advise against it. Just keep auto_increment value for all orders. If you want to count how many orders given user has made, you can do this in other ways.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.