0

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

2
  • 1
    Please provide your table structure with data and expected result and what you have tried so far Commented Aug 8, 2013 at 15:54
  • I would do it from the application side, like if($mailbox['Mail']['box'] = 1){ $mailboxvar = inbox } - this isn't quite what you asked for, but it might achieve the same effect Commented Aug 8, 2013 at 15:55

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0
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

Comments

0

You can use a nested IF statement:

select if(folder=0, 'Outbox', if(folder=1, 'Inbox', 'Sent')) as folder, msg_id,... from messages; 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.