2 tables.
1 with the primary name and an associated key.
2nd table with the primary key and a field for alias.
That way you are not limited on number of aliases and do not have to change structure when you decide you need 4 instead of 5.
Primary table:
Id - auto-increment primary key
Primary_name Varchar how ever long you need it to be
Alias table:
id - auto-increment key
primary_id - points at key in primary table
alias_name varchar however long you need
Example:
Primary table:
1 Primary Name 1
2 Primary Name 2
3 Primary Name 3
Alias Table:
1 1 Alias for Primary 1 1
2 1 Alias for Primary 1 2
3 1 Alias for Primary 1 3
4 2 Alias for Primary 2 1
5 2 Alias for Primary 2 2
Pull primary with their aliases
Select a.primary, b.alias
from primary_table a left outer join alias_table b on a.id=b.primary_id
order by primary, alias
Hope that makes sense
|