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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:38:07+00:00 2026-06-13T12:38:07+00:00

I am joining tables in mysql but I have one table that holds dates

  • 0

I am joining tables in mysql but I have one table that holds dates as so:

table: cutoff

      date       roomid  
---------------------------  
    2012-11-03     25
    2012-11-04     25
    2012-11-05     25
    2012-11-06     25

And here is my SQL query:

SELECT t.RoomId, t.USD, t.MXN, i.Image, a.RoomName, a.RoomDesc, cu.date FROM Tarifas AS t 
INNER JOIN Images AS i ON i.RoomId = t.RoomId
INNER JOIN Availability AS a ON a.RoomId = t.RoomId 
INNER JOIN cutoff AS cu ON cu.roomid = t.RoomId AND cu.date NOT BETWEEN '$from' and '$to' 
WHERE t.Start <= '$from' AND t.End >= '$from' ORDER BY USD 

I want to get all the rows where the date is not in the cutoff table. But it is giving me the opposite! I do not know what to do, any help here would be greatly appreciated!

EIDT TO ADD TARIFA TABLE:

table: tarifas
RoomId      Start         End       USD       MXN
---------------------------------------------------
25        2012-11-01   2012-11-20   60.00    620.00
26        2012-11-01   2012-11-20   80.00    820.00
27        2012-11-01   2012-11-20   55.00    570.00
  • 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-13T12:38:08+00:00Added an answer on June 13, 2026 at 12:38 pm

    Try this (edited):

    SELECT t.RoomId, t.USD, t.MXN, i.Image, a.RoomName, a.RoomDesc
    FROM Tarifas AS t 
    INNER JOIN Images AS i ON i.RoomId = t.RoomId
    INNER JOIN Availability AS a ON a.RoomId = t.RoomId 
    WHERE t.RoomID NOT IN
        (SELECT DISTINCT roomid FROM cutoff
        WHERE date BETWEEN '$from' AND '$to')
    AND t.Start <= '$from' AND t.End >= '$from'
    ORDER BY USD 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hi everyone im beginner in php & mysql here im joining 3 tables but
I have data split across several mysql tables to prevent data duplication but joining
I have some tables that I'm joining in a query with Postgres (9). However,
I have a problem with joining 2 tables together, as follows Table 'jobs' id
i have a problem with joining three tables in mysql. lets say we have
I have a high scores table that stores a list of scores and dates.
I am having a problem sorting results from joining tables that have to be
let's say I have three tables (MySQL), one for users, one for tags and
I have multiple MySQL tables containing varying numbers of columns. After joining three of
I've got three tables in a MySql database that I'm joining in a query

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.