Re: SELECT syntax

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

In Oracle (and maybe others) you can use


select case
when answer=1
then trivia_answer_1
when answer=2
then trivia_answer_2
when answer=3
then trivia_answer_3
when answer=4
then trivia_answer_4
else null
end answer
from bible_trivia_table
OR

You can select all of them and process in PHP, should not be too hard to
come up with a couple of lines of code to display only 1 variable  based on
the value of variable 5. Overhead should be pretty minimal as well
You'll be writing something to display a value anyway


Jack van Zanen

-------------------------
This e-mail and any attachments may contain confidential material for the
sole use of the intended recipient. If you are not the intended recipient,
please be aware that any disclosure, copying, distribution or use of this
e-mail or any attachment is prohibited. If you have received this e-mail in
error, please contact the sender and delete all copies.
Thank you for your cooperation


On Thu, Oct 13, 2011 at 6:24 AM, Ron Piggott <ron.piggott@xxxxxxxxxxxxxxxxxx
> wrote:

>
> In my Bible_Trivia table I have the columns
>
> `trivia_answer_1`, `trivia_answer_2`, `trivia_answer_3`, `trivia_answer_4`,
> `answer`
>
> `answer` is an integer always with a value of 1 to 4. Is there a way to use
> the value of `answer` to only select the correct trivia answer?
>
> This doesn’t work, but this is the idea I am trying to achieve:
>
> SELECT `trivia_answer_`answer`` FROM `Bible_trivia`
>
> Thanks in advance,
>
> Ron
>
>
>
> www.TheVerseOfTheDay.info <http://www.theverseoftheday.info/>
>

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux