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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:52:53+00:00 2026-06-13T19:52:53+00:00

I am trying to fetch data from multiple tables depending on what is selected

  • 0

I am trying to fetch data from multiple tables depending on what is selected in a dropdown menu. My dropdown menu consists of a list of ID’s (001, 002, etc).

Once a user selects one of them, I am using AJAX to dynamically fetch data depending on what was selected. I was able to fetch a single value depending on what was selected but having problems when multiple tables are involved.

My tables are set up like this:

Inventory table:

inven_ID (primary)
cost
description

Order table:

order_ID(primary)
orderdesc

Sale table:

inven_ID
order_ID
quantity
primary(inven_ID,order_ID)

My query is as follows:

$QRY = "SELECT 
          inven_ID, 
          order_ID, 
          cost, 
          description 
        FROM 
          Inventory, 
          Order, 
          Sale 
        WHERE Inventory.inven_ID = Sale.inven_id 
        AND Sale.order_ID = Order.order_ID 
        AND Order.order_ID ='".$q."'";

The $q represents the value from the dropdown menu (which I checked is valid). I am getting the error Column ‘inven_ID‘ in field list is ambiguous. Basically, when they select some order id from the drop down (say 001), it looks for order_ID in my Order table, and fetches the inven_ID/cost/description of that particular order ID.

Eg. if someone ordered parts xy, yz, xyz for cost 10,20,30.

Selecting 001 would bring up:
001 xy 10
001 yz 20
001 xyz 30

I think I am not joining tables properly since the error says its ambiguous.

Any help on this?

edit: yes that fixed the problem, quite obvious that I did not catch it.

  • 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-13T19:52:55+00:00Added an answer on June 13, 2026 at 7:52 pm

    In the column list of your select, you just need to specify which inven_ID you want to retrieve. For instance:

    SELECT Inventory.inven_ID, ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using an Oracle DB and I'm trying to fetch data from its tables
I am trying to fetch data from three tables on the basis of most
Hi, I am trying to fetch data from two tables using join but i
i am trying to fetch data from SQLite to list view but my list
I'm trying to fetch data from two tables however it doesn't seem to be
I'm trying to fetch data from a page that resides on an intranet. The
I'm trying to fetch data from a div (based on his id), using PHP's
I am trying to fetch data from internet, parse it and then show the
I'm trying to fetch some JSON data from my server like so: var a
I'm trying to fetch the XML data from a query to the api without

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.