heloo everyone, i am new to mysql and php. here i am diplaying my data by joining 3 tables.what this query is doing

1) displaying course name
2) displaying subject name
3) displaying status if any

there are three statuses (applied, accepted, rejected)

what i want to display is
1) course name
2)subject name
3)donot display the status if is is accepted.

after putting condition of != in SELECT query it doesnot show any accepted status but it doesnot remove the whole row instead its showing the whole row with no status and a blank space where it was showing accepted
how i can solve this problem,, hope i explained my question clearly any kind of help will be appreciated, thanx in advance :) here's my code

$result = mysql_query("SELECT courses.id AS cid, courses.title, courses.subjectsid, subjects.id AS sid, subjects.subjectname,  requestrecord.status
FROM courses JOIN subjects ON courses.subjectsid = subjects.id 
LEFT JOIN requestrecord 
ON courses.id = requestrecord.coursesid AND requestrecord.accountsid=".$_SESSION['id']." AND requestrecord.status!='accepted' ");
                                                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^      
Member Avatar for LastMitch

@Riu 2009

after putting condition of != in SELECT query it doesnot show any accepted status but it doesnot remove the whole row instead its showing the whole row with no status and a blank space where it was showing acceptedhow i can solve this problem,, hope i explained my question clearly any kind of help will be appreciated, thanx in advance :) here's my code

Did you create a table called 'status'? I think the reason why it didn't appear is because you didn't create a table called status.

Your status table should have these: applied, accepted, rejected

and when you run the query it will show one of these applied, accepted, rejected

i have created the table requestrecord and i have a column in that tble called status

$result = mysql_query("SELECT courses.id AS cid, courses.title, courses.subjectsid, subjects.id AS sid, subjects.subjectname,  requestrecord.status
FROM courses JOIN subjects ON courses.subjectsid = subjects.id 
LEFT JOIN requestrecord 
ON courses.id = requestrecord.coursesid AND requestrecord.accountsid=".$_SESSION['id']." 

WHERE requestrecord.status!='accepted' ");


                                                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^      

I have replaced AND with WHERE in last line, if you put AND, it will become part of your left join condition, to filter record, you must give condition in WHERE clause.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.