Novice question on retreival order

P

PSI

If no explicit sorting is specified on a query are the records
returned "guaranteed" to be in the same order as created?
(ie implicitely sorted on the primary key? )

I have a list box loaded from a table where selecting the last entry
has some extra meaning ( ie "Other" causes an edit field to be
enabled. ). I was hoping to avoid having an extra field in the table
to indicate which one is "Other". I also didn't want to hardcode a
string compare becausethe data loaded may may be a different language
).

Thanks
Frank
 
J

Joe Fallon

There is no guarantee of sort order with using an Order By clause.

You can add an item to your list box by writing your regular query to get
the list and then writing a 2nd query with a hard coded value like <ALL> or
<OTHER> or whatever.
Then do a UNION.
 
J

John Vinson

If no explicit sorting is specified on a query are the records
returned "guaranteed" to be in the same order as created?

No. The records will be returned in whatever order the query engine
finds most convenient; this may differ from control to control or even
from day to day.
(ie implicitely sorted on the primary key? )

There is absolutely no guarantee that the primary key will retain the
order of records selected, and a Table will not necessarily be
displayed in primary key order in any case.
I have a list box loaded from a table where selecting the last entry
has some extra meaning ( ie "Other" causes an edit field to be
enabled. ). I was hoping to avoid having an extra field in the table
to indicate which one is "Other". I also didn't want to hardcode a
string compare becausethe data loaded may may be a different language

If you want to sort records in a controllable or predictable order,
you must - no options, no choices - use a Query sorting by a field or
fields in the table.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top