Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2012
    Posts
    4

    Unanswered: mysql - column value refer to same table column

    based on title, can it be done with mysql? dont no specific keyword to search on google

    for example
    i got column a, column b,

    column a has it value, and column b, it value refer to column a.

    can be it done?

    (sorry for my english)

  2. #2
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    Please publish sample data and expected result from the sample data.

    Like this way...

    Source Table:
    Code:
    my_table looks like...
    column_a
    ----------
    abc
    12345
    x
    06/23/2012
    80.87
    Note: I don't know what data in your table.
    So, I showed some data types in the column which might be not compatible each oher.
    Actually, the data wouldn' t be mixed such way.


    Expeced result from the data:
    Code:
    column_a   | column_b
    -----------+----------
    abc        | ???
    12345      | ???
    x          | ???
    06/23/2012 | ???
    80.87      | ???
    I'm sorry, if I missed the point.

  3. #3
    Join Date
    Jun 2012
    Posts
    4
    Quote Originally Posted by tonkuma;6557864
    Expeced result from the data:
    [CODE
    column_a | column_b
    -----------+----------
    abc | ???
    12345 | ???
    x | ???
    06/23/2012 | ???
    80.87 | ???
    [/CODE]
    take your table..lets say

    value in column a is 'abc', then the value in column b just based on column a,
    that mean also 'abc' (automatically)

    Code:
    column_a   | column_b
    -----------+----------
    abc        | abc (<--this value based on value on column a)
    it is posibble?

  4. #4
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    So, why not
    Code:
    SELEC column_a
        , column_a AS column_b
     FOM  ...
    ...
    ?

  5. #5
    Join Date
    Jun 2012
    Posts
    4
    Quote Originally Posted by tonkuma View Post
    So, why not
    Code:
    SELEC column_a
        , column_a AS column_b
     FOM  ...
    ...
    ?
    thx,
    but i dont want the select statement. i want to create column.

  6. #6
    Join Date
    Jun 2012
    Posts
    4
    nvm.. already find the solution.
    i learnt that we cannot create it..
    using trigger instead

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •