Description is basically the question.
I have a CSV file that I load into a table in my database. I then (SELECT * FROM tablename into OUTFILE ‘…’) and check that the two CSVs are equal. I do this to make sure that the database was loaded properly.
My problem is that one of the fields is an ENUM type. The CSV I use to load the table contains the integer representation (for reasons I can’t control) and the outfile CSV contains the string representation. Is there any way for me to cast the ENUM into its integer value when creating the outfile? I feel as though this should be an easy thing to do but I wasn’t able to find an answer on Google.
Note: I have to do this for many different tables so it’s difficult for me to treat each table on an individual basis.
You need to use a numeric context to get the enum’s integer value. Try this:
This will evaluate the enum_field in a numeric context, which will return the index value.