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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:40:53+00:00 2026-06-09T16:40:53+00:00

So basically I have two tables: u_contracts +——–+———+——————————+ | id | user_id | reschedule_wait_confirm_till

  • 0
So basically I have two tables:

u_contracts

+--------+---------+------------------------------+
| id     | user_id | reschedule_wait_confirm_till |
+--------+---------+------------------------------+
| 107742 |   19982 | 2012-08-08 17:10:41          |
|  38548 |    4622 | 2012-08-08 10:24:42          |
|  98483 |   36707 | 2012-08-08 21:39:08          |
|  45165 |   17632 | 2012-08-08 23:13:57          |
| 131285 |   47527 | 2012-08-08 08:33:58          |
| 131686 |   40194 | 2012-08-08 12:18:09          |
|  91749 |   11021 | 2012-08-08 12:22:05          |
+--------+---------+------------------------------+

restruct_mail_history

+----+---------+---------------------+
| id | user_id | _date               |
+----+---------+---------------------+
|  1 |   47527 | 2012-08-07 12:16:51 |
+----+---------+---------------------+

Now I need to select all user_id’s from u_contracts that have date reschedule_wait_confirm_till for tomorrow and that have no todays entires in restruct_mail_history.

So far I have a working query like this:

SELECT
  uc.user_id
FROM
  u_contracts uc
WHERE
  uc._status = 6
  AND DATE( uc.reschedule_wait_confirm_till ) = DATE( ADDDATE( now(), 1 ) )
  AND uc.user_id NOT IN ( SELECT rmh.user_id FROM restruct_mail_history rmh WHERE DATE( rmh._date ) = DATE( now() ));

Output:

19982
4622
36707
17632
40194
11021

Now I don’t like the SELECT statement in WHERE, so I was planing to make LEFT JOIN like this:

SELECT
  uc.user_id
FROM
  u_contracts uc
LEFT JOIN
  restruct_mail_history rmh
ON
  uc.user_id = rmh.user_id
WHERE
  uc._status = 6
  AND DATE( uc.reschedule_wait_confirm_till ) = DATE( ADDDATE( now(), 1 ) );

Output:

19982
4622
36707
17632
47527
40194
11021

Now this gives me all u_contracts result, but when I add the necessary parameter AND DATE( rmh._date ) != DATE( now() ) it gives me absolutelu no results.

Any idea what I’m doing wrong?

EDIT If iI change the last line to AND DATE( rmh._date ) = DATE( now() ), it gives me only the results that should not be in the list, witch id correct. Why doesn’t it work the opposite way?

Thank you already.

  • 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-09T16:40:54+00:00Added an answer on June 9, 2026 at 4:40 pm

    try this:

    SELECT uc.user_id
    FROM u_contracts uc
         LEFT JOIN restruct_mail_history rmh
            ON uc.user_id = rmh.user_id
    WHERE uc._status = 6 AND
          DATE( uc.reschedule_wait_confirm_till ) = DATE( ADDDATE( now(), 1) ) AND
          (rmh.user_id IS NULL OR DATE( rmh._date ) != DATE( now() ));
    

    see here: Visual Explanation Of Joins.

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

Sidebar

Related Questions

Basically I have a database with two tables, that is, Updates table and Images
I'm new to these types of MySQL Queries. Basically, I have two tables in
I basically have two tables: A(id int, name varchar(10), info varchar(10)) B(id int, item
Ok here it is. i have two tables: products and product_sizes so basically my
I have two tables. The first Holds a list of classes with basically an
Basically, I have two tables that have a 1 to 1 relation. When I
I am stuck on a LINQ query. Basically I have two tables linked by
I am a bit stumped on this. Basically I have two tables: Page: id
I have two tables User & User Log . User log table basically logs
Basically, I have two tables, admin_privilege and admin_roll_privilege. I'm trying to write 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.