Please help me understanding Query (1 Viewer)

SachAccess

Active member
Local time
Today, 04:57
Joined
Nov 22, 2021
Messages
389
Hi Experts,

I need to your help to understand two queries. Values in the queries are dummy.
Will take help from here for 2 queries and will try to use the knowledge to understand rest of the queries.
Was able to understand few basic things from below but was not able to understand what and how exactly below statements are working.
Kindly help me to understand, how to break these statements and draw conclusion.

Thanks.

Code:
SELECT Table_My_123.My_Rank, "String_1" & [Table_My_123].[My_Col_1] & "String_2" & [Table_My_456].[My_Col_2] AS Comment
FROM Table_My_123 LEFT JOIN Table_My_456 ON Table_My_123.My_Rank = Table_My_456.[Chassie_Number]
WHERE ((([Table_My_456].[My_Col_2]=[Table_My_123].[My_Col_1])=0));


UPDATE Table_My_123 LEFT JOIN Table_My_456 ON Table_My_123.My_Rank = Table_My_456.[Chassie_Number] SET Table_My_123.My_Col_1 = [Table_My_456].[My_Col_2]
WHERE ((([Table_My_456].[My_Col_2]=[Table_My_123].[My_Col_1])=0));
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 07:27
Joined
May 7, 2009
Messages
19,245
the Where Clause does not make sense, to me.
are you comparing [Table_My_456].[My_Col_2] and [Table_My_123].[My_Col_1] to 0?
 

SachAccess

Active member
Local time
Today, 04:57
Joined
Nov 22, 2021
Messages
389
Hi @arnelgp , thanks for the help. To be specific, this is not written by me. Using as example to study from somewhere else.
Have a nice day ahead. :)
 

GPGeorge

Grover Park George
Local time
Yesterday, 16:27
Joined
Nov 25, 2004
Messages
1,873
I agree with the Gasman. That's a clumsy way of expressing the comparison, but it should work.

Stripping out the bonus parenthesis Access provides for free:

WHERE ([Table_My_456].[My_Col_2]=[Table_My_123].[My_Col_1])=0;

That says, in logical terms:

Compare the values in these two fields in these two tables, that is compare [Table_My_456].[My_Col_2] to [Table_My_123].[My_Col_1]

Where there is a match, Access returns -1 (for true) or 0 (for false). So the result of that comparison is either -1 or 0 for all records.

Next it says:

Now, select only the records which returned 0.

I think, and I could be wrong, so test this for yourself, it could be expressed:

WHERE [Table_My_456].[My_Col_2]<> [Table_My_123].[My_Col_1]

Before accepting this, or any suggestion, of course, it's a good idea to verify it.
 

SachAccess

Active member
Local time
Today, 04:57
Joined
Nov 22, 2021
Messages
389
Is that a very clumsy way of saying = and not = ie, False ?
Hi @Gasman thanks for the help. Please give me some to check original reference, however as far as I know I have just copied it as it is.
Have a nice day ahead. :)
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 07:27
Joined
May 7, 2009
Messages
19,245
if you really want to test that Both fields are 0 and not any number or not even null:

Where (Nz([Table_My_456].[My_Col_2], 0) + Nz([Table_My_123].[My_Col_1], 0)) = 0
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 19:27
Joined
Feb 19, 2002
Messages
43,293
Whoever wrote the SQL originally is not a good role model.

Something = something2 = 0 is just a confusing way of saying something <> something2 assuming George analyzed the expression correctly.


PS, not that anyone would care, but all those underscores make my teeth grind, not to mention the trailing numbers which indicate repeating groups.
 

SachAccess

Active member
Local time
Today, 04:57
Joined
Nov 22, 2021
Messages
389
Hi @Pat Hartman thanks for the help. My bad, will take care going forward while creating dummy data.
Have a nice day ahead. :)
 

Users who are viewing this thread

Top Bottom