Friends,
I have a strange need, and I canโt decide my way. The great and powerful Google helps a little because of the recycling of keywords (as you will see). You can help?
What I want to do is store data of several types in one column in MySQL.
This is a database equivalent to a C join (and if you are looking for MySQL and Union, you obviously get a whole bunch of information on the UNION keyword in SQL).
[The manifested and simplified case follows] So, let's say we have people who have names - and STORMTROOPERS - who have TK numbers. You cannot have a NAME and TK number. You are either BOB SMITH or TK409.
In C, I could express this as a union, for example:
union { char * name; int tkNo; } EmperialPersonnelRecord;
This makes it so that I either save a pointer to a char array or an identifier in the EmperialPersonnelRecord type, but not both.
I am looking for the MySQL equivalent in a column. Int, double or varchar (255) (or any combination) will be stored in my column. But it will occupy only the space of the largest element.
Is it possible?
(of course, everything is possible, given enough time, money and will - I mean, is it possible that I am poor, lazy and in the deadline ... otherwise "out of the box")
c mysql unions union
Michael
source share