Greenguy's Board


Go Back   Greenguy's Board > General Business Knowledge
Register FAQ Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
Old 2018-01-30, 12:48 PM   #6
sarettah
Asleep at the switch? I wasn't asleep, I was drunk
 
Join Date: Apr 2005
Posts: 214
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
sarettah is offline   Reply With Quote
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:52 PM.


Mark Read
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc