Subtables in MySQL

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Subtables in MySQL

Post by anjanesh »

Is there any way to create sub-tables for each row in MySQL.
Like FirstName,MiddleName,LastName table for a field named Name in main table.

Code: Select all

`Main tbl`
    |-Id
    |-Roll
    |-Name
    |  |-First
    |  |-Middle
    |  |-Last
    |-Address
    |-Phone
Something like this ?
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

no
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

No, but name could always be a number, and link to a table called name with first, middle, last in it?
Or you could use a period or | to seperate them, then use explode to get them by themselves..

OR you can do it the easiest way and just have 3 columns.. ;)
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

LiLpunkSkateR wrote:
OR you can do it the easiest way and just have 3 columns.. ;)
This is what i prefer, beucase name can always be found as name = first + middle + last

in MySQL:

SELECT CONCAT(first, ' ', middle, ' ', last) AS name)

:)
Post Reply