Jump to content

Recommended Posts

Hi! Can someone help me here? I just got this code from other topics and use it for my system but i have a problem

 

$idList = join (',', array_map('intval', array_keys($_POST['answers'])));		
$sql = "SELECT QuestionId, answer
FROM tblquestion_mc WHERE QuestionId IN ($idList";

 

what i am trying to do is to join my table: tblquestion_default to that code above but i don't know how to. 

 

My tables contain this:

 

table name: tblquestion_mc

QuestionId | Answer

 

table name" tblquestion_default

QuestionId | Answer

Link to comment
https://forums.phpfreaks.com/topic/275771-joining-two-tables-with-the-same-rows/
Share on other sites

Try:

 

SELECT o.QuestionId, o.Answer AS Answer1, t.Answer AS Answer2 FROM tblquestion_mc AS o JOIN tblquestion_default AS t ON o.QuestionId = t.QuestionId WHERE o.QuestionId IN ($idList);
Edited by jcbones
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.