Reputation:
i'd like to store into a mailbox table the folder, the message should be inside as an int. Like 0 is inbox, 1 is outbox, ...
Is there a way to make the result of the query give me back a result like 'INBOX' for the stored value of 0?
Greetings
Upvotes: 0
Views: 76
Reputation: 53525
You can use a nested IF statement:
select if(folder=0, 'Outbox', if(folder=1, 'Inbox', 'Sent')) as folder, msg_id,... from messages;
Upvotes: 0
Reputation: 47619
You may store them as ENUM('INBOX', 'OUTBOX')
. They will be stored as integers.
It'll be possible to write them as strings and as integer representation. They will be read as text by default.
Upvotes: 1
Reputation: 2602
select case message when 1 then 'INBOX' when 2 then 'OUTBOX' END from your table
Is this what you are looking for?
Refer this for more information
Upvotes: 0