MySQL Forums
Forum List  »  Newbie

Re: New Database from Excel Data
Posted by: Phillip Ward
Date: January 26, 2023 05:42AM

Quote

How would I set up an ID something like an inspection ID ...

If your Inspection table has an auto-incrementing ID column, then you get this for free.
Simply insert the Inspection record without the ID field in the column list and the database will generate a value for you. Use the last_insert_id() function to retrieve that value for inserting into other, related, tables.

Quote

... with an ID of 'Inspection 1'

Don't do this.
Just store the numeric ID value (say, 123) and construct the Human-readable form as and when you need it.

select concat( 'Inspection ', ID ) title, ...
from Inspections 
where ...

+----------------+
| title          | 
+----------------+
| Inspection 123 |
+----------------+

Regards, Phill W.

Options: ReplyQuote


Subject
Written By
Posted
January 23, 2023 05:17PM
January 24, 2023 03:03AM
Re: New Database from Excel Data
January 26, 2023 05:42AM


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.