« first day (2101 days earlier)      last day (557 days later) » 

2:21 AM
@SunMaungOo can you elaborate on your problem? What's the context for what you're trying to do?
 
 
3 hours later…
5:00 AM
    @TehShrike , I will simplified the problem.

    There are rows of the data as below

    Table=Employee

    Id  |  ListId |   Name

    1   |       1    | Red

    2   |       1      | Green

    3   |       1      | Blue

Notice that they have the same ListId

and I wanted to select "a column based on row data".

In above data, I wanted my query to return as


ListId  | Employee1 | Employee2 | Employee3

1        |    Red         |      Green   |  Blue
The context is that there are "List of Data" that it have been entered before and they wanted to view the data as column instead of rows.

Basically, the it should be easy to view and modify all the data. I mean, the user wanted to view all the employee in the department.

I am sorry if it is confusing. I try to simplified it as best as I can. If it is still confusing feel free to tell me.
The "maximum row of List of Data" is predefined and will not changes. But I want to make it flexible (if possible) since you can't predict when will the requirements changes
 
 
4 hours later…
9:20 AM
A quick question if I may; When using innodb, on a table which has a reflective relationship, can a foreign key constraint be set up? I am getting an error when I try to make this constraint.
 
 
6 hours later…
3:02 PM
@SunMaungOo any logic that facilitates "how the data should be viewed" should be done at the last moment in the application logic, not in the data query.
If you try to make your database queries account for view-level logic, you will find yourself in a world of sticky pain
@iain what is a "reflective" relationship?
 
@TehShrike Hello could be lost in translation there, that is the French terminology. In French, a table that references its self is said to have a reflective relationship.. Such that it defines a genealogical relationship within a tables rows; I am not familiar with the correct English term for this and apologize for any confusion.
 
3:27 PM
@iain ah, gotcha
I'm not sure of the correct relational schema term either, but I'd guess "self-referential"
I'm not sure if that's possible with InnoDB :-o
 
Ok, that would explain the error; To be done with code then; Thanks for your input.
 

« first day (2101 days earlier)      last day (557 days later) »