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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:40:26+00:00 2026-05-25T03:40:26+00:00

I am having trouble working out how to return the correct row in a

  • 0

I am having trouble working out how to return the correct row in a table given that said table is relational. The two tables are shown below.

web_quote_models table

id | model       | product_id | cpu_id | ram_id | hdd_id | os_id | opt_id 
=========================================================================
1  | 000001      | 1          | 1      | 1      | 1      | 1     | 1
2  | 000002      | 1          | 2      | 2      | 2      | 2     | 2
3  | 000003      | 1          | 3      | 3      | 3      | 3     | 3
4  | Custom      | 0          | 0      | 3      | 4      | 4     | 4

web_quote_component_cpu table

id | name
=========================================================================
1  | Intel® Core™ i3 2100 3.1GHz dual-core
2  | Intel® Core™ i5 2500 2.7GHz quad-core        
3  | Intel® Core%trade; i7 2600 3.4GHz 8mb Cache dual-core

So what I need to achieve is a query that will look inside the web_quote_models table and match the model field with a $_SESSION[‘model’] then match the web_quote_models.cpu_id field with the web_quote_component.id.

This is what I have so far; I cant be too far off I think.

("
 SELECT web_quote_component_cpu.name
 FROM web_quote_component_cpu
 LEFT JOIN web_quote_models
 ON web_quote_component_cpu.id='web_quote_models.cpu_id'
 AND web_quote_models.name='".$_SESSION['model']."'
");

A massive thank you in advance to anyone that helps.

Dan.

  • 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-05-25T03:40:26+00:00Added an answer on May 25, 2026 at 3:40 am

    I don’t think you’re far off at all. I believe that all you need to do is stop quoting web_quote_models.cpu_id:

     SELECT web_quote_component_cpu.name
     FROM web_quote_component_cpu
     LEFT JOIN web_quote_models
     -- note lack of quotes in the following line:
     ON web_quote_component_cpu.id=web_quote_models.cpu_id
     AND web_quote_models.name='".$_SESSION['model']."'
    

    Edit

    Based on the comment, I would personally re-write the query:

     SELECT web_quote_component_cpu.name
     FROM web_quote_component_cpu WHERE ID IN
     ( SELECT ID FROM WEB_QUOTE_MODELS WHERE 
       web_quote_models.name='".$_SESSION['model']."' );
    

    Though I would suspect that swapping that last AND with a WHERE would be sufficient:

     SELECT web_quote_component_cpu.name
     FROM web_quote_component_cpu
     LEFT JOIN web_quote_models
     -- note lack of quotes in the following line:
     ON web_quote_component_cpu.id=web_quote_models.cpu_id
     WHERE web_quote_models.name='".$_SESSION['model']."'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having trouble working out how to get a simple fade in fade
I am having trouble with a homework question that I've been working at for
I'm having trouble trying to figure out why my formatDate is not working correctly.
I'm having trouble figuring out why the following is not working: My custom JS
Using Mongokit with Python. Having some trouble working out get the last n number
I'm having trouble working out how to retrieve the identifier of a selected value
I'm having trouble working out the syntax for a nested partial template specialization. I
I am having trouble working out how to create a simple pop-and-drop effect for
I'm having some trouble working out how to control program flow and not use
I'm working on my first Core Data-backed app and am having trouble figuring out

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.