Jump to content

Duplicated results in query


mjs87

Recommended Posts

Hi I am trying to select the document titles stored in a database. However I only want to select the title for a document that belongs to the user that is logged in, furthermore the user (teacher) teaches a maximum of 2 subject I therefore am only selecting documents that belong to subject 1. The problem I am having is that the results are displayed twice.

 

Here are my tables:

 

tblPlan

docname

doctitle

subject

uname

datecreated

datemodified

modifiedby

 

 

tblSubjectUser

uname

subject

subjectnum

 

The Select statement:

 

$uname = $_SESSION['uname'];

$sSQLDoc="SELECT tblPlan.docname, tblPlan.doctitle, tblPlan.datecreated, tblPlan.datemodified, tblPlan.modifiedby
FROM tblPlan INNER JOIN tblSubjectUser ON tblPlan.subject = tblSubjectUser.subject
WHERE (((tblPlan.uname)='$uname') AND ((tblSubjectUser.subjectnum)='1'))";
$rsDoc = mysql_query($sSQLDoc);

Link to comment
https://forums.phpfreaks.com/topic/186389-duplicated-results-in-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.