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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:45:15+00:00 2026-06-03T16:45:15+00:00

I have the following SQL Query. SELECT MIN(PLD.available_date) as ‘FROM’, MAX(PLD.available_date) as ‘UNTIL’, (

  • 0

I have the following SQL Query.

SELECT MIN(PLD.available_date) as 'FROM', MAX(PLD.available_date) as 'UNTIL', (
CASE
    WHEN DATEDIFF('2012-04-01', '2012-04-10') = (COUNT(PLD.available_date) - 1)
    THEN 'Yes'
    ELSE 'No'
END) as isAvailable, PL.*
FROM `parking_lot_dates` as PLD
INNER JOIN parking_lots as PL ON PLD.plid = PL.plid
WHERE PLD.available_date BETWEEN '2012-04-01' AND '2012-04-10'
GROUP BY PLD.plid

But is it possible to put that INNER JOIN into a CASE? what i’m trying to accomplish is that when the isAvailable column’s value is Yes then grab the extra information otherwise don’t grab it.

I tried putting the INNER JOIN between a CASE statement but it didn’t work.

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-06-03T16:45:17+00:00Added an answer on June 3, 2026 at 4:45 pm

    You can’t do a conditional join in the way you want, but you could instead:

    SELECT PLD.FROM, PLD.UNTIL, IF(PLD.isAvailable, 'Yes', 'No') AS isAvailable, PL.*
    FROM (
        SELECT   plid
          ,      MIN(available_date) AS `FROM`
          ,      MAX(available_date) AS `UNTIL`
          ,      DATEDIFF('2012-04-01', '2012-04-10') = COUNT(*) - 1 AS `isAvailable`
        FROM     parking_lot_dates
        WHERE    available_date BETWEEN '2012-04-01' AND '2012-04-10'
        GROUP BY plid
      ) AS PLD LEFT JOIN parking_lots AS PL ON (
        PLD.isAvailable AND PL.plid = PLD.plid
      )
    WHERE NOT (PLD.isAvailable AND PL.plid IS NULL)
    

    The subquery performs the grouping operation on the parking_lot_dates table, and we make an outer join between that and the parking_lots table in order to have records even when the join condition is not satisfied. Learn about SQL joins.

    The WHERE clause imitates the effect of your INNER JOIN by eliminating any results for which there was not a matching record in parking_lots when one was expected; it can be omitted if you didn’t actually want that behaviour.

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

Sidebar

Related Questions

I have following SQL query SELECT TOP 10000 AVG(DailyNodeAvailability.Availability) AS AVERAGE_of_Availability FROM Nodes INNER
I have the following which works in SQL Query Analyzer . select oh.* from
I have the following SQL query: select AuditStatusId from dbo.ABC_AuditStatus where coalesce(AuditFrequency, 0) <>
I have the following SQL query: select ID, COLUMN1, COLUMN2 from (select ID, COLUMN1,
I have following SQL query: SELECT Count(*) AS CountOfRecs FROM tblAccount INNER JOIN tblAccountOwner
I have the following SQL query - SELECT * FROM dbo.LocalContacts WHERE name LIKE
I have the following query sql query: select * from Articles ar left join
I have the following sql query : SELECT DATE(procedures.start) date, name, COUNT(procedure_types.id) count FROM
I have the following SQL query: SELECT * FROM table WHERE field_1 <> field_2
I have the following SQL query: SELECT DISTINCT business_key FROM Memory WHERE concept <>

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.