MySQL Forums
Forum List  »  General

MYSQL filter do not work
Posted by: Alexandre Salomé
Date: June 09, 2021 07:37AM

Hi,

I'm in need of a help to filter the elements of "A" (table tc_positions ) based on another "B" (table tc_devices) , using the select command.

I have in "A" the columns: "id", "fixtime"
I have in "B" the column: "positionID" , where "positionID" is a foreign key corresponding to the "id" of table "A"


I want to use the command:

SELECT * FROM tc_positions WHERE fixTime < DATE(DATE_ADD(NOW(), INTERVAL -20 DAY)) AND id NOT IN (SELECT positionId FROM tc_devices)


and this command is returning empty, which is not true!!!!


If I execute only "SELECT * FROM tc_positions WHERE fixTime < DATE(DATE_ADD(NOW(), INTERVAL -20 DAY))" I have more than 4 millions of rows, (that is, distinct id)


If I execute only "SELECT positionId FROM tc_devices" I have 300 records with distinct/unique "positionID"


For me this command is OK, but do not return the correct value

What I need to do?

Regards

Alex

Options: ReplyQuote


Subject
Written By
Posted
MYSQL filter do not work
June 09, 2021 07:37AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.