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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:35:43+00:00 2026-05-14T05:35:43+00:00

The SQL query without where statement runs great and outputs good results, but when

  • 0

The SQL query without where statement runs great and outputs good results, but when I include WHERE condition it shows Unknown column ‘date1’ in ‘where clause’. What’s the problem?

SELECT
  IF( e.weekly,
      DATE_ADD(DATE(e.time),
      INTERVAL CEIL(DATEDIFF('2010-04-08', e.time)/7) WEEK ),
   DATE(e.time)) AS `e.date1`,
   `v`.`lat`,
   `v`.`lng` 
FROM `events` AS `e`
INNER JOIN `venues` AS `v` ON e.venue_id = v.id
WHERE e.date1 > '2010-09-01'
  • 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-14T05:35:44+00:00Added an answer on May 14, 2026 at 5:35 am

    You cannot alias a column with <tablename>.<name>. Instead of AS e.date1 you really have to use AS date1.
    (If you omit the backticks to create the alias you will get an SQL syntax error.)

    But this is only one reason. The other is that aliases can’t be used in WHERE clauses.

    From the documentation:

    An alias can be used in a query select list to give a column a different name. You can use the alias in GROUP BY, ORDER BY, or HAVING clauses to refer to the column

    and

    Standard SQL disallows references to column aliases in a WHERE clause. This restriction is imposed because when the WHERE clause is evaluated, the column value may not yet have been determined.

    But you can use aliases in a HAVING clause:

    SELECT
      IF( e.weekly,
        DATE_ADD(DATE(e.time),
        INTERVAL CEIL(DATEDIFF('2010-04-08', e.time)/7) WEEK ),
        DATE(e.time)) AS `date1`,
      `v`.`lat`,
      `v`.`lng` 
    FROM `events` AS `e`
    INNER JOIN `venues` AS `v` ON e.venue_id = v.id
    HAVING date1 > '2010-09-01'
    

    or you repeat the whole IF statement in the where clause.

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

Sidebar

Related Questions

If user input is inserted without modification into an SQL query, then the application
I would like to turn this query to regular inline sql without using stored
How do I query a MS Access database directly from SQL Management Studio, without
What SQL query shows me the tables & indexes used by a view on
We are using the following SQL query to produce monthly averages. The statement is
How do you make an SQL statement that returns results modified by a subquery,
SQL query: SELECT ArticleCategories.Title AS Category, Articles.Title, Articles.[Content], Articles.Date FROM ArticleCategories INNER JOIN Articles
SQL query which select the record from three tables and there is no relation
This SQL query was generated by Microsoft Access 2003, and works fine when run,
My sql query is only returning the children of the parent I need it

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.