MySQL Forums
Forum List  »  Newbie

Re: Zero fill
Posted by: Phillip Ward
Date: January 10, 2017 06:08AM

Quote

...how i can make sure that the autoincrement of all tables keep in line so that i can querie a WHERE statement: projectnameID and projecctaddressID and projectmanagersID is the same

You can't, nor should you even try.

Database != SpreadSheet

Each Project will have a unique id.
Each ProjectAddress will have its own unique id, but will include the id of the Project to which it belongs.
Each ProjectManager will have its own unique id, but will include the id of the Project to which they belong.

Something like this:

select * from Projects ; 
+----+-----------+ 
| id | name      | 
+----+-----------+ 
|  1 | Blue Book | 
+----+-----------+ 

select * from ProjectAddresses ; 
+----+------------+---------------------+------------+ 
| id | project_id | street              | city       | 
+----+------------+---------------------+------------+ 
| 22 |          1 | Fifth Avenue        | New York   | 
| 33 |          1 | Pennsylvania Avenue | Washington | 
+----+------------+---------------------+------------+ 

select * from ProjectManagers ; 
+-----+------------+-----------------+ 
| id  | project_id | name            | 
+-----+------------+-----------------+ 
| 444 |          1 | Fred Flintstone | 
| 555 |          1 | Barney Rubble   | 
| 666 |          1 | Dino            | 
+-----+------------+-----------------+

Regards, Phill W.

Options: ReplyQuote


Subject
Written By
Posted
December 28, 2016 12:06PM
December 28, 2016 12:56PM
Re: Zero fill
January 10, 2017 06:08AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.