Re: What does this query do?



On Thu, 29 Sep 2005 10:50:06 +0100, "Keith"
<keith.wilby@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:

>I've inherited an Access file in which there is the following query:
>
>SELECT tblItem.InstanceNo, "PL" &
>Left([tblItem].[Label],InStr([tblItem].[Label],"-")-1) AS Parent
>FROM tblItem, tblItem AS tblItem_1
>WHERE ((("PL" &
>Left([tblItem].[Label],InStr([tblItem].[Label],"-")-1))=[tblItem_1].[InstanceNo]));
>
>So the same table is included twice and [InstanceNo] is used as criteria for
>[Parent]. I would have thought that the query would return two identical
>columns but it doesn't. My brain's not working today, which part of the
>plot am I missing?

I would guess that it lists the Instance and Parent for each Parent
row that exists with respect to any row of the table. So, assume you
have 40 rows in the table. Assume that for a given row, say 39, the
Parent is defined as "PL001"; that is, the Label starts with "001-".
Row 39 is displayed once for each row of the 40 rows where Instance =
"PL001".

If row 39 is defining the parent for Instance number 859 (Instance =
"PL859") as "001" (Label starts with "001-") then list row 39 once for
each row in the table where Instance = "PL001".

mike



.



Relevant Pages

  • Re: What does this query do?
    ... this query matches every record to every other ... the 'parent' of PLnn whose label is mm-tt will be PLmm, ... > FROM tblItem, tblItem AS tblItem_1 ...
    (comp.databases.ms-access)
  • Re: Query vs form with child & parent: Deleting rows
    ... If you delete a parent record, and have 5 related tables to that main ... These child records will delete even if you just delete main ... the setup of the query WILL NOT EFFECT this ... So, if we have Customers, and Invoices tables, a left join would give us: ...
    (microsoft.public.access.forms)
  • Re: Deleting duplicate parents and grouping children to single par
    ... You will need to build the action query as a SQL statement to execute. ... To reassign 24 to 18, and then kill 24, this is the basic code: ... duplicate fields and then use a MIN function to identify the first ParentID ... undesirable parent record. ...
    (microsoft.public.access.tablesdbdesign)
  • RE: Parent-Child relations in a dataset
    ... How do I keep pending parent and children in synch? ... that actually exist in the database. ... use those placeholder values for your pending child rows. ... "SELECT SCOPE_IDENTITY" query to retrieve the last identity ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Updating and Retrieving Data
    ... How do I keep pending parent and children in synch? ... that actually exist in the database. ... use those placeholder values for your pending child rows. ... "SELECT SCOPE_IDENTITY" query to retrieve the last identity ...
    (microsoft.public.dotnet.framework.adonet)