Ezilon.com - Target Your Audience, be Seen in Your Region

MySQL Select Row Order

You are viewing this site as a guest. Join our community to get your questions answered and share knowledge. Active members may advertise and ask for a website critique.
teammatt3's picture
Moderator

He has: 1,902 posts

Joined: Sep 2003

SELECT * FROM SectionQuestion WHERE SectionID = 5

When those rows are retrieved, am I always guaranteed that they will be retrieved in the same order (as long as no indexed column is added to the table, or more rows added with a SectionID of 5)?

After a couple of test queries, the answer appears to be yes, but I'd like a definitive answer Smiling

teammatt3's picture
Moderator

He has: 1,902 posts

Joined: Sep 2003

And yes, I know that I could add another column that contains the order in it, but that's not my question.

Greg K's picture
Moderator

He has: 1,664 posts

Joined: Nov 2003

try deleting out a row from the middle of the ones returned to you, then add another row.

I did this earlier today, and it put the new record where the one I just deleted was.

When you need to make sure it is the same, give it rules to follow to make sure can (add PK or Order field and sort with it).

-Greg

[This space intentionally left blank]

Cool Geek Supplies: www.ThinkGeek.com

teammatt3's picture
Moderator

He has: 1,902 posts

Joined: Sep 2003

I did this earlier today, and it put the new record where the one I just deleted was.

I experienced the same behavior. I'm still unsure if I'm always guaranteed that will happen but I guess I'll take my chances. Smiling