Note that there are some explanatory texts on larger screens.

plurals
  1. POMYSQL - Creating a Temporary Column that Indicates If Questions are Answered
    primarykey
    data
    text
    <p>Hi I'm currently developing a sort of quiz application. In "Discover" section I get popular and latest questions. But when I get them I should also check if question is already answered by current user or not.</p> <p>Here are my tables: questions: (media_id is primary key, player_id is creator of the question)</p> <pre><code>media_id - player_id - answer0 - answer1 - ... </code></pre> <p>answers: (media_id is primary key, player_id is the person who answers the question)</p> <pre><code>media_id - player_id - result - ... </code></pre> <p>This is how I get popular questions:</p> <pre><code>select * from questions where order by popularity_count </code></pre> <p><strong>EDIT:</strong> Let me show what I want to achieve by examples:</p> <p>questions rows:</p> <pre><code>media_id - player_id - answer0 - answer1 0123456 abc123 bla bla 6543210 hjk789 lor ips </code></pre> <p>answers rows:</p> <pre><code>media_id - player_id - result 6543210 abc123 1 </code></pre> <p>So when user "abc123" gets the popular questions results should be:</p> <pre><code>media_id - player_id - answer0 - answer1 - is_answered 0123456 abc123 bla bla 0 6543210 hjk789 lor ips 1 </code></pre> <p>The problem is I need a temporary column in the result of query that indicates if question is replied by the current user or not. How can I achieve this? </p> <p>I can find if question is already answered or not for popularity section by using two queries. First I get the popular questions then I simply check if question is answered or not for every questions which seems so ineffective way. How can I achieve this with only one query?</p> <p>Thank you!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload