If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > mysql - column value refer to same table column

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-23-12, 11:58
lockmaey lockmaey is offline
Registered User
 
Join Date: Jun 2012
Posts: 4
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)
Reply With Quote
  #2 (permalink)  
Old 06-23-12, 13:05
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,752
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.
Reply With Quote
  #3 (permalink)  
Old 06-23-12, 13:20
lockmaey lockmaey is offline
Registered User
 
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?
Reply With Quote
  #4 (permalink)  
Old 06-23-12, 13:58
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,752
So, why not
Code:
SELEC column_a
    , column_a AS column_b
 FOM  ...
...
?
Reply With Quote
  #5 (permalink)  
Old 06-23-12, 14:01
lockmaey lockmaey is offline
Registered User
 
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.
Reply With Quote
  #6 (permalink)  
Old 06-23-12, 17:15
lockmaey lockmaey is offline
Registered User
 
Join Date: Jun 2012
Posts: 4
nvm.. already find the solution.
i learnt that we cannot create it..
using trigger instead
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On