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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:56:55+00:00 2026-05-13T20:56:55+00:00

Here is the query that I am working on: SELECT `unitid`, `name` FROM apartmentunits

  • 0

Here is the query that I am working on:

SELECT `unitid`, `name` FROM apartmentunits
WHERE aptid = (
    SELECT `aptid` FROM rentconditionsmap WHERE rentcondid = 1 AND condnum = 1
)

What I am having trouble figuring out is how to write this to add more rentcondition limiters to filter this list down more.

SELECT `aptid` FROM rentconditionsmap WHERE rentcondid = 1 AND condnum = 1

Data:

CREATE TABLE IF NOT EXISTS `rentconditionsmap` (
   `rcid` bigint(10) unsigned NOT NULL AUTO_INCREMENT, 
   `rentcondid` int(3) unsigned NOT NULL, 
   `condnum` tinyint(3) unsigned NOT NULL, 
   `aptid` bigint(10) unsigned DEFAULT NULL, 
   PRIMARY KEY (`rcid`), KEY `aptid` (`aptid`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=18 ;

INSERT INTO `rentconditionsmap` 
  (`rcid`, `rentcondid`, `condnum`, `aptid`) 
VALUES 
  (1, 1, 1, 1), 
  (2, 2, 1, 1), 
  (3, 3, 0, 1), 
  (4, 4, 1, 1), 
  (5, 8, 0, 1);

CREATE TABLE IF NOT EXISTS `apartmentunits` (
  `unitid` bigint(10) NOT NULL AUTO_INCREMENT, 
  `aptid` bigint(10) NOT NULL, 
  `name` varchar(6) NOT NULL, 
  `verified` tinyint(1) NOT NULL DEFAULT '0', 
  `rentcost` int(4) unsigned DEFAULT NULL, 
  `forrent` tinyint(1) NOT NULL DEFAULT '0', 
  `unittypekey` varchar(2) DEFAULT NULL, 
  `sqft` smallint(6) DEFAULT NULL, 
  PRIMARY KEY (`unitid`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=121 ;

INSERT INTO `apartmentunits` 
  (`unitid`, `aptid`, `name`, `verified`, `rentcost`, `forrent`, `unittypekey`, `sqft`) 
VALUES 
  (1, 1, '3', 1, 540, 0, '2B', NULL), 
  (2, 1, '5', 1, NULL, 0, '2B', NULL), 
  (3, 1, '7', 1, NULL, 0, '2B', NULL), 
  (53, 1, '1', 1, NULL, 0, '2B', NULL), 
  (54, 1, '2', 1, NULL, 0, '2B', NULL), 
  (55, 1, '4', 1, 570, 0, '2B', NULL), 
  (56, 1, '6', 1, NULL, 0, '2B', NULL), 
  (57, 1, '8', 1, NULL, 0, '2B', NULL), 
  (58, 1, '9', 1, NULL, 0, '2B', NULL), 
  (59, 1, '10', 1, NULL, 0, '2B', NULL), 
  (60, 1, '11', 1, NULL, 0, '2B', NULL);
  • 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-13T20:56:55+00:00Added an answer on May 13, 2026 at 8:56 pm

    As Eric J said as a comment:

    Try changing = to IN

    SELECT `unitid`, `name` FROM apartmentunits
    WHERE `aptid` IN (
        SELECT `aptid` FROM rentconditionsmap WHERE rentcondid = 1 AND condnum = 1
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the issue I am having: I have a large query that needs
So here is the original query SELECT SUM(PickQty), SUM(ReqQty), AssignmentID, StopID FROM PickRequest GROUP
Bit of a strange problem here... I've got an update query that isn't working,
I'm working on creating a SQL query that will pull records from a table
I'm having trouble working out a query. I've tried subqueries, different joins and group_concat()
So firstly here's my query: ( NOTE:I know SELECT * is bad practice I
Here's an example of the query I'm trying to convert to LINQ: SELECT *
I'm trying to write a query that returns the most recent GPS positions from
I have a working query that retrieves the data that I need, but unfortunately
I have below a working query that needs to be simplified. The reason is

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.