« first day (1223 days earlier)      last day (3095 days later) » 

12:41 PM
Okay this question is beyond basic, but I'm migrating SQL to MongoDB and bool fields are -1 or 0 in the sql database which is false, lol.
 
hi all
need help on a "complex" query please
I have a table called "testMain" for example, which looks like this :

test_id
test_name
test_comment
test_related
and another table, called "related" for example, which looks like this :

related_id
related_name
related_comment
table TEST can have a NULL value in the "test_related" field
if it is not null, then test_related is a "related_id" from the related table
What I want is to get some records like this :

test_id | test_name | test_comment | test_related | related_name
something like SELECT test_id,test_name,test_comment,test_related,related_name FROM testMain .... and then? join? left join? inner join? ... ON test_related = related_id

BUT in the testMain records, the test_related can be null, so sometimes, the related_name column i'd like to retrieve is useless since it does not exist, there will be no match..
 

« first day (1223 days earlier)      last day (3095 days later) »