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

  • SEARCH
  • Home
  • 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 8552505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:26:18+00:00 2026-06-11T14:26:18+00:00

Hi having a problem on how to structure my sql statment would appreciate any

  • 0

Hi having a problem on how to structure my sql statment would appreciate any help on how should i do it right. What i am trying to achieve is to show all advisers from tbl_adviser and while also showing the class section_id the teacher is assigned from tbl_section. This is what i have come up so far.

 $qry_display = "SELECT a.section_id,b.*
     from tbl_section As a LEFT OUTER JOIN tbl_adviser AS b ON a.section_id
                                 = b.adviser_id Where bname='$branch'"; 

My idea on $branch is that the user may only view the same data if they have the same bname

This is my DB structure:

tbl_section:

section_id
section_name
sy
adviser_id
level
bname

tbl_adviser:

adviser_id
lname_a
fname_a
address
bname
photo
cnumber

And this is how i suppose to show:

 while (@$get_display = mysql_fetch_object(@$sql_display))
            {

            ?><tbody>
            <tr>
<td  class="text"><a href="adviser_view.php?&id=
<?php echo $get_display->adviser_id ?>">
            <?php echo @$get_display->adviser_id; ?></a></td>
                <td  class="text"><?php echo @$get_display->lname_a ?></td>
                <td  class="text"><?php echo @$get_display->fname_a ?></td>
                <td  class="text"><?php echo @$get_display->section_id ?></td>


            </tr>
            </tbody>

Edit: Error spatting out is “Column ‘bname’ in on clause is ambiguous”.

  • 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-11T14:26:19+00:00Added an answer on June 11, 2026 at 2:26 pm

    Your ON looks to me to be incorrect:

    ON a.section_id = b.adviser_id
    

    Should probably be:

    ON a.adviser_id = b.adviser_id
    

    You also need to disabmiguate the bname column – SQL doesn’t know which table it is supposed to be coming from in the WHERE clause:

    Where bname='$branch'
    

    Can be:

    Where a.bname='$branch'
    

    Or:

    Where b.bname='$branch'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I' having a problem allocating a structure in a function. Here is the code(I'm
I'm having a problem getting XCode to deal with a particular file structure that
Im having a problem with a multimodule project in maven/jenkins. For example my structure
I'm trying to optimize SQL queries in Akonadi and came across the following problem
I'm having a problem with layout structure. Here is a mockup: https://i.stack.imgur.com/PFMLi.jpg And code:
I am having a problem with image paths in my css. My directory structure
i having some problem with TList and BinarySearch. I have this structure: PDoubleEstr =
I'm having difficulty with this problem. I have a table with this structure: OrderID
Having a few problems with Ormlite and Android/Sqlite so any help appreciated. The database
Im having a problem returning a structure. It says Run-Time Check Failure #2 -

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.