Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7960385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:44:27+00:00 2026-06-04T04:44:27+00:00

I need to filter data based on one table, but i dont know the

  • 0

I need to filter data based on one table, but i dont know the correct usage for the select from function in php mysql. The below code shows what i am trying to do, but I think you can use multiple SELECT.

$query_Student = "SELECT Project_Title, Project_Lecturer FROM projects WHERE Project_id = 
 (SELECT Proj_id FROM project_course WHERE Cour_id = (SELECT Course_id from courses WHERE     
Code = (SELECT Course FROM users WHERE Username = ".$_SESSION['MM_Username']."))"

Can anyone offer any assistance to what I need to write instead?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:44:28+00:00Added an answer on June 4, 2026 at 4:44 am

    What you want to do is not exactly clear to me, but to make your query work you need to put single quotes around $_SESSION['MM_Username'], like gogowitsch already said.

    Also another closing paranthese is missing. So your query should look like this:

    $query_Student = "SELECT Project_Title, Project_Lecturer FROM projects WHERE Project_id = 
     (SELECT Proj_id FROM project_course WHERE Cour_id = (SELECT Course_id from courses WHERE     
    Code = (SELECT Course FROM users WHERE Username = '".$_SESSION['MM_Username']."')))"
    

    But…

    That is not a very well written query.

    I’m just guessing now, but maybe this is what you are looking for:

    SELECT 
    p.Project_Title, 
    p.Project_Lecturer 
    FROM projects p
    INNER JOIN project_course pc ON p.Project_id = pc.Proj_id
    INNER JOIN courses c ON pc.Cour_id = c.Course_id
    INNER JOIN users u ON c.Code = u.Course
    WHERE u.Username = 'yourUserName';
    

    If not, show us the tables you are using (do a SHOW CREATE TABLE projects; and so on for every table you are using and post it here) and maybe what output you expect, then we can really help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to filter out junk data in SQL (SQL Server 2008) table. I
I need to implement a mean filter on a data set, but I don't
I'm trying to work on this website wherein I need to filter the data
I need to pass a complex object representing a data filter to an action
I need to filter alphabetic and non alphanumeric characters from a string to make
I need a filter function for a project I'm working on. I am thinking
I need to filter multiple rows in dataview. Here I used rowfilter. But, I
To filter a table output of selected entries from a single table i would
I need to gather Distinct Id's from a particular table using LINQ. The catch
I have the following Query and i need the query to fetch data from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.