Different queries but the same?

  • Thread starter Thread starter Linda RQ
  • Start date Start date
L

Linda RQ

Hi Everyone,

Access 2003. I accidently double clicked on the wrong thing in a new query
based on another query. In the query grid, I added the
qryVentThpyWithinLastArea and double clicked on the *. It only filled one
column of my grid but when I ran the query, it showed all the fields from
the query. I then dragged down Area field and added my criteria. I had
been taught to double click on the blue title bar and then drag all the
fields to the grid then add my criteria. Both ways give me the same data.
What is the differnce?

I pasted the sql below so you can see what's going on...

SELECT qryVentThpyWithinLastArea.*, qryVentThpyWithinLastArea.AreaName
FROM qryVentThpyWithinLastArea
WHERE (((qryVentThpyWithinLastArea.AreaName)="PICU"));


SELECT qryVentThpyWithinLastArea.PtLName, qryVentThpyWithinLastArea.PtID,
qryVentThpyWithinLastArea.AdmitDtTm, qryVentThpyWithinLastArea.DCDtTm,
qryVentThpyWithinLastArea.AdmitNum, qryVentThpyWithinLastArea.PtThpyID,
qryVentThpyWithinLastArea.AreaName, qryVentThpyWithinLastArea.TherapyTypeID,
qryVentThpyWithinLastArea.TherapyDesc, qryVentThpyWithinLastArea.ThpyStDtTm,
qryVentThpyWithinLastArea.ThpyEndDtTm, qryVentThpyWithinLastArea.AdmLOS,
qryVentThpyWithinLastArea.VentLOS
FROM qryVentThpyWithinLastArea
WHERE (((qryVentThpyWithinLastArea.AreaName)="picu"));

Thanks,
Linda
 
I had
been taught to double click on the blue title bar and then drag all the
fields to the grid then add my criteria.

well, that's a quick way for beginners. there are many instances where you
don't need *every* field in a table to be included in a query; in those
cases, you should select only the fields you *do* need - one by one - from
the table's fieldlist in the query design grid.

when you do need all table fields in the query, either method you described
is okay. be aware, though, that when you use the asterisk (*) to call all
the fields, and then add a specific field *again* so as to enter criteria on
that field, you're going to get that field TWICE in the query output - the
second time with an automatically generated fieldname, usually "Expr1". the
solution in this scenario is the uncheck the checkbox in the field you've
explicitly added for criteria purposes, so it doesn't show up twice.

hth
 
Thanks

Linda

tina said:
well, that's a quick way for beginners. there are many instances where you
don't need *every* field in a table to be included in a query; in those
cases, you should select only the fields you *do* need - one by one - from
the table's fieldlist in the query design grid.

when you do need all table fields in the query, either method you
described
is okay. be aware, though, that when you use the asterisk (*) to call all
the fields, and then add a specific field *again* so as to enter criteria
on
that field, you're going to get that field TWICE in the query output - the
second time with an automatically generated fieldname, usually "Expr1".
the
solution in this scenario is the uncheck the checkbox in the field you've
explicitly added for criteria purposes, so it doesn't show up twice.

hth
 
Back
Top