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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:46:53+00:00 2026-06-13T02:46:53+00:00

When running the query below, I end up with a MYSQL error in PHPMyAdmin:

  • 0

When running the query below, I end up with a MYSQL error in PHPMyAdmin:

#1054 - Unknown column 'wd.Datum' in 'having clause'

This query belongs in a time reporting application, where users report time worked on projects on a daily basis. There’s a table for days that are expected working days, a table of all employees and a table with information about the current work rate. The last table is also used to determine when a user was employed.
The idea is to get all working days and all users in order to (in a later query) select days that a user has forgotten to report times for. I want to limit the result set to days that users has been employed.
Here’s my query:

SELECT emp.ID AS user
FROM (workdays wd, employees emp)
     INNER JOIN workrates wr ON (emp.ID=wr.UserId)
WHERE (wd.Datum<'2012-11-15')
GROUP BY WEEK(wd.Datum, 3), user
HAVING wd.Datum>=MIN(wr.FromDate)

(May be related to http://bugs.mysql.com/bug.php?id=13551 which is about a syntax change introduced in MySQL version 5, that causes this message if you forget certain parenthesis)

The MySQL server is running version “5.1.63-0+squeeze1” on Debian.

EDIT: I changed the first query row to

SELECT emp.ID AS user, wd.Datum

as suggested by Vijay, and the query works! Though I don’t understand why.

  • 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-13T02:46:54+00:00Added an answer on June 13, 2026 at 2:46 am

    Every column you use in the HAVING clause of your query must be present in the selected columns. HAVING works on the calculated values (for instance if you use the SUM() function you can use the calculated sum in the HAVING clause.)

    Also note that if you give a column an alias you have to use the alias in the HAVING clause.

    For more information on hidden columns and HAVING: http://dev.mysql.com/doc/refman/5.0/en/group-by-hidden-columns.html

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

Sidebar

Related Questions

I am running this below code but it returns an error as: undefined index:
I am running the query below in Sybase application which works great but the
Running this query takes a long time: SELECT host,ip FROM arecords WHERE ip IN
After running this query statement with my database: select * from articles where content
Im running this query on the same server as the web application, so SPQuery.ExpandRecurrence
I'm running a query which looks like this SELECT parent.field, child.field FROM parent JOIN
Is it possible to get around mysql_unbuffered_query()'s limitation of having one query running at
Here is my mysql query below. Through many helpful questions and comments I am
This is a simplified version of a query we are running where we need
For the problem below, I got the query working. But when I am running

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.