Red 09 Posted September 19, 2003 Share Posted September 19, 2003 My current solution is a table i call index (the parent?), wich holds a field for unique id and a reference to a unique entry in another table (the child?). 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. Quote Link to comment Share on other sites More sharing options...
s0urce Posted September 19, 2003 Share Posted September 19, 2003 Hi. 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. Source Quote Link to comment Share on other sites More sharing options...
nabeel21 Posted September 19, 2003 Share Posted September 19, 2003 if i understood ur question correctly, 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 Quote Link to comment Share on other sites More sharing options...
Red 09 Posted September 22, 2003 Author Share Posted September 22, 2003 Thanks for the replies. 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..). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.