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 8409455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:54:56+00:00 2026-06-09T23:54:56+00:00

Just asking is it possible in php to perform sql statment’s in 1 function.

  • 0

Just asking is it possible in php to perform sql statment’s in 1 function.

What my sql really does is fetch data from three tables in my database.
I am currently unsure of what method to use. Inner join would pop into it but i forgot what the proper syntax. so i was thinking about this.

$qry_display = "SELECT student_id,
section_id,level,photo,address,father_occupation,father_phone,father_company,mother_occupation,
mother_phone,mother_company 
from tbl_er 
where student_id='$id' AND level="3rd Year"";

The above statement would retrieve the information from tbl_er these would be the students history.

$qry_display = "SELECT fname,
sex,
lname,
mname,
birth_date,
birth_place,
address,
father,
father_degree,
mother,
mother_degree,
from tbl_enroll where student_id='$id'";

The above statement would retrieve part of the information from tbl_enroll these would be the students core unchangeable data. Also the first statement has “section_id” to be retrieved. so my idea is to retrieve that value so it would be used for the last sql which is.

$qry_display = "SELECT section_name,adviser_id,schoolyr 
from tbl_section 
where student_id='$id' AND section_id='$sid'";

and my idea to on how to get the section_id is before the last statement i would put.

    $sid= section_id  (I am unsure if this will work.)

Also will this statement trigger all three statements in one function?

        $sql_display = mysql_query($qry_display) or die (mysql_error());

Thank you, Appreciate any feedback.

  • 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-09T23:54:57+00:00Added an answer on June 9, 2026 at 11:54 pm

    There is a lot wrong with this, and you probably will not get what you are looking for even if you work out the bugs, so lets start with writing this as 1 coherent query with left joins (good call btw).

    $qry_display = "SELECT
                a.student_id, a.section_id, a.level, a.photo, a.address, a.father_occupation, a.father_phone, a.father_company, a.mother_occupation, a.mother_phone, a.mother_company,
                b.fname, b.sex, b.lname, b.mname, b.birth_date, b.birth_place, b.address, b.father, b.father_degree, b.mother, b.mother_degree,
                c.section_name, c.adviser_id, c.schoolyr
                FROM tbl_er AS a
                LEFT OUTER JOIN tbl_enroll AS b ON a.student_id = b.student_id
                LEFT OUTER JOIN tbl_section AS c ON a.section_id = c.section_id
                WHERE a.student_id=".$id." AND a.level='3rd Year'";
    

    The last join doesn’t care about the student_id because the section / advisor relationship does not depend on a student.

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

Sidebar

Related Questions

Possible Duplicate: Reference - What does this symbol mean in PHP? Found an image
Possible Duplicate: Any way to specify optional parameter values in PHP? just randomly came
Possible Duplicate: Sending HTML email from PHP Using PHP to send an email. I
This is most likely not possible, but I'm just asking this to check... I'm
I don't know if this is possible using regex. I'm just asking in case
Just asking if I have the right understanding System.out.println(); System is the package out
It seems to me that using unanchored namespaces is just asking for trouble later
i just was asking about the existence of a headfirst book(iPhone&iPad development) which covers
I hope this question is not 'controversial' - I'm just basically asking - has
Just out of curiosity, asking this Like the expression one below a = (condition)

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.