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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:55:07+00:00 2026-06-18T02:55:07+00:00

Table pc – code model speed ram hd cd price 1 1232 500 64

  • 0

Table pc –

 code   model   speed   ram hd  cd  price
 1  1232    500 64  5.0 12x 600.0000
 10 1260    500 32  10.0    12x 350.0000
 11 1233    900 128 40.0    40x 980.0000
 12 1233    800 128 20.0    50x 970.0000
 2  1121    750 128 14.0    40x 850.0000
 3  1233    500 64  5.0 12x 600.0000
 4  1121    600 128 14.0    40x 850.0000
 5  1121    600 128 8.0 40x 850.0000
 6  1233    750 128 20.0    50x 950.0000
 7  1232    500 32  10.0    12x 400.0000
 8  1232    450 64  8.0 24x 350.0000
 9  1232    450 32  10.0    24x 350.0000

Desired output –

model   speed   hd
1232    450 10.0
1232    450 8.0
1232    500 10.0
1260    500 10.0

Query 1 –

SELECT model, speed, hd
FROM pc
WHERE cd = '12x' AND price < 600
OR
cd = '24x' AND price < 600

Query 2 –

SELECT model, speed, hd
FROM pc
WHERE cd = '12x' OR cd = '24x' 
AND price < 600

Query 1 is definitely working correctly, however when i tried to reduce the query to use price at once only, it is not showing the correct result..let me know what I am missing in the logic.

Find the model number, speed and hard drive capacity of the PCs having
12x CD and prices less than $600 or having 24x CD and prices less than
$600.

  • 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-18T02:55:08+00:00Added an answer on June 18, 2026 at 2:55 am

    Since AND comes before OR, your query is being interpreted as:

    WHERE (cd = '12x') OR ((cd = '24x') AND (price < 600))
    

    Or, in words: All PCs having 12x CD, or PCs < $600 having 24x CD


    You need to use parentheses to specify order of operations:

    WHERE (cd = '12x' OR cd = '24x') AND price < 600
    

    Or, you can use IN:

    WHERE cd IN ('12x', '24x') AND price < 600
    

    See Also: http://dev.mysql.com/doc/refman/5.5/en/operator-precedence.html

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

Sidebar

Related Questions

Table Definition Model Definition Code using MyRandomizer.Models; namespace MyRandomizer { class Program { static
Table is a Mongoid model that must dinamically map to different databases/tables # app/models/table.rb
table **salesrule_coupon**: fileds as the following: coupon_id code 1 Registered_send_5 2 test table: salesrule_coupon_usage
Table: Accounting date_due date_paid amount_due amount_paid category_type 2012-08-12 2012-08-12 500 450 Income 2012-08-13 2012-08-17
table offer id_offer offer state 600 A 0 629 B 0 tags id_tags tags
table : id (integer primary key) data (blob) I use mysql and sqlalchemy. To
Table --------------------------------------------- | id | first_name | middle_name | last_name | --------------------------------------------- | 1
Table structure id (p) | date | id2 (fk) | id3 (fk) where (p)
Table A has two columns: ID and name I want to input 3 ID
Table #1: qa_returns_items Table #2: qa_returns_residues I have a long time trying to get

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.