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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:45:20+00:00 2026-05-16T10:45:20+00:00

My Query does not work when I have not set the ProcessorID in myComputer

  • 0

My Query does not work when I have not set the ProcessorID in myComputer table
How can I make a query that will show me the ProcessorName when I have a value assigned in ProcessorID or NULL when I don’t?

CREATE TABLE myProcessor
(    
 ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
 Name VARCHAR(255) NOT NULL
) ENGINE=InnoDB;  

INSERT INTO myProcessor (Name) VALUES ("xeon");

CREATE TABLE myComputer 
(
 ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
 Name VARCHAR(255) NOT NULL,
 ProcessorID INT DEFAULT NULL,
 FOREIGN KEY (ProcessorID) REFERENCES myProcessor(ID) ON DELETE CASCADE
) ENGINE=InnoDB;  

INSERT INTO myComputer (Name) VALUES ("Newton");

SELECT p.Name as ProcessorName, c.Name as ComputerName
FROM myComputer c, myProcessor p 
WHERE c.ProcessorID = p.ID
AND c.Name = "Newton";

The above select query currently returns null if the processorID has not been set.

  • 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-16T10:45:20+00:00Added an answer on May 16, 2026 at 10:45 am

    Your current query returns no rows if a computer is not assigned a processor, as in the example you provided.

    You may want to use a left outer join, instead of the implicit inner join you are using:

    SELECT     p.Name as ProcessorName, c.Name as ComputerName
    FROM       myComputer c
    LEFT JOIN  myProcessor p ON (c.ProcessorID = p.ID)
    WHERE      c.Name = "Newton";
    

    Returns:

    +---------------+--------------+
    | ProcessorName | ComputerName |
    +---------------+--------------+
    | NULL          | Newton       |
    +---------------+--------------+
    1 row in set (0.00 sec)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 510k
  • Answers 511k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer use each: http://api.jquery.com/each/ $("a").each(function(){ //do something with the element here.… May 16, 2026 at 5:09 pm
  • Editorial Team
    Editorial Team added an answer You are confusing the endpoint URL with the claimed identifier… May 16, 2026 at 5:09 pm
  • Editorial Team
    Editorial Team added an answer Use X-SENDFILE. Most webservers will support it either natively, or… May 16, 2026 at 5:09 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have an IQueryable (PartHistories) that will return a set of objects. I have
I have a dynamic query which I call and I put the Result set
//get var of posted info so user does not //have to reinsert if if
I have an issue with jquery where elements are not found when the query
I am using Zend_Db with the Pdo_Mysql driver. This query does not give any
We have a form that allows a user to filter a list with by
I have form1 passing a query string parameter(param1) to form2. I pass param1=true from
In my .htaccess file I have a set of rules as follows: RewriteRule ^dir/page1$
I have a following query (simplified): SELECT Id FROM dbo.Entity WHERE 1 = ALL
I have a problem with a query using hibernate. The entity class EntityClass has

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.