Page 1 of 1

Subtables in MySQL

Posted: Sun Aug 29, 2004 8:21 am
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 ?

Posted: Sun Aug 29, 2004 9:20 am
by malcolmboston
no

Posted: Sun Aug 29, 2004 10:11 am
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.. ;)

Posted: Sun Aug 29, 2004 12:10 pm
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)

:)