Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query is pulling ALL fields when only 2 are requested

Status
Not open for further replies.

HMJ

Technical User
Nov 29, 2002
58
0
0
US
We have a situation that started about 2-3 months ago. When we make a query using MS Access, it automatically pulls ALL fields for any and all tables queried.

Example:
I query for LastName, FirstName; sort by LastName FirstName.
No other fields.

This is the SQL statement that is generated:
Code:
SELECT Personnel.LastName, Personnel.FirstName, *
FROM Personnel
ORDER BY Personnel.LastName, Personnel.FirstName;

The comma and astrisk on the first line are killing me.

Anyone know why this is happening, and/or how to stop it?

Thank You!

Harry J.
 
why don't you just change the SQL?

SELECT Personnel.LastName, Personnel.FirstName
FROM Personnel
ORDER BY Personnel.LastName, Personnel.FirstName;

the asterick means 'give me all fields in the table', remove it and you should just get the two you need.

Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual

Essential reading for anyone working with databases: The Fundamentals of Relational Database Design
 
You may also look at "Tools; Options; Tables/Queries" and ensure that "Output all fields" is not checked.

cranebill Just as a note ... "he" (lespaul) is a "she".
 
I was just going to let it go, but thanks for the clarification!

les
 
lespaul

Well programming does sort of render its practitioners into genderless trolls ... but at least you started out life with the female persuasion. I hope you're not suggesting that you needed the clarification!
 
Lespaul,

We have been doing that, but when you generate as many queries as we do on a daily basis it becomes a pain in the @$$ to do that every five minutes or so. We were hoping to find a way to eliminate it from the start.


Golom,

When I get into work in the morning, I will look that up and see if it checked or not.


Thank you all for the help.

Harry J.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top