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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:40:47+00:00 2026-05-23T16:40:47+00:00

The following mysql query… SELECT a.*, b.*, ( SELECT COUNT( * ) FROM lp_units

  • 0

The following mysql query…

SELECT a.*, b.*,
       ( 
            SELECT COUNT( * ) 
            FROM lp_units c 
            WHERE c.property_id = a.property_id 
        ) AS unitcount
FROM lp_property a,
     lp_property_confidential b
WHERE a.property_id = b.property_id
AND c.unitcount<= a.no_of_units
AND a.account_id = '1'

returns an error…

Unknown column 'c.unitcount' in 'where clause'

I think my query would be understandable. solve it to run….

Thanks in advance…

  • 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-23T16:40:48+00:00Added an answer on May 23, 2026 at 4:40 pm

    Don’t use c.unitcount. Just unitcount. unitcount is not a column of c but rather of the temporary table generated by the subquery.

    However, this query is probably better written as a join anyway.

    Try this query

    SELECT
      a.*,
      b.*,
      COUNT(c.property_id) as unitcount
      FROM lp_property a
      JOIN lp_property_confidential b ON a.property_id = b.property_id
      JOIN lp_units c ON c.property_id = a.property_id
      WHERE
      a.account_id = '1'
      GROUP BY a.property_id
      HAVING unitcount <= a.no_of_units
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following MySQL query: select `userID` as uID, (select `siteID` from `users` where `userID`
I am running the following MySQL query : select * from combinations where family_type='f597';
I've got the following MySQL query: <?php $sql = SELECT * FROM my_table; $result
I am using the following mysql query for grouping referrersource. SELECT referrersource,count(referrersource) as counts
I have the following MySQL query and tables from which I am querying: SELECT
I have the following MySQL query: SELECT p.*, IF(COUNT(ms.PropertyID) > 0,1,0) AS Contacted, pm.MediaID,
Take a look at the following mySQL query: SELECT fname,lname FROM users WHERE users.id
I'm confounded. The following MySQL query: SET @a := 0; SELECT * FROM users;
I have the following MySql query: select t1.* from Table1 t1 inner join Table2
I'm trying to run the following MySQL query: SELECT * FROM user u JOIN

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.