How can entries from several tables have unique ID in DB?
Posted 19 September 2003 - 08:37 AM
Does mySQL have a built-in better way to \"share\" id sequences? Example: I make an entry into TableA and it gets id 1, the next two entries are in TableB and gets id 2 and 3, I add one more entry to TableA again and this gets id 4... and so on.
Posted 19 September 2003 - 10:55 AM
The only way I know of that you could do that is that you do it manually. Search for the highest id in all of your tables, then increase by one and add a new entry.
This is an odd thing to do though. I always try to keep my id\'s from 1 to infinity (actually, 65536) in all tables, no matter what. What are you trying to do? There might be a better solution.
Posted 19 September 2003 - 11:55 AM
U can return the max sequence number by
Select max(unique_id) from table;
Where unique_id is a column that stores sequence numbers..
Then u can use that number and increment it by 1 and insert it into the database.
-hope it helps
Posted 22 September 2003 - 09:36 PM
What I\'m trying to do is to make a intranet site that holds different kinds of data (articles, calenders, contact lists, image galleries, etc) in different tables.
I have a crude system with main categories and sub categories. the reason I want to have unique id\'s is so I can mix entries from different tables in the sub categories.
Example: Category B, has a sub category K. Inside sub categroy K I want to place 3 articles, and 1 contact list. I want to be able to sort these by alphabet or date as if they were all entries from the same table.
I\'m not sure I understood what nabeel21 meant, but I\'ll look into it. I\'ll probably figure it out somehow, but I\'m not sure if It would be the best solution I want to give the users full ability to create categories, subcategories and put entries in these from the different tables I mentioned (articles, etc..).
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users