| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |

03-31-10, 04:50
|
|
Registered User
|
|
Join Date: Mar 2010
Posts: 18
|
|
Find values that are not in sequence
|
|
Hello,
How to find values that are not in sequence ?
A
B
C
D
Z
E
F
G
or something like this:
1
2
3
8
4
5
6
Each of the highlighted values is not in the proper sequence, how to find those ?
Thanks
|
|

03-31-10, 06:30
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
|
|
like i mentioned on devshed, you have to give more information
please show the actual query that produces these results
as you know, the rows of a table do not have an inherent order, and especially not a table consisting of only one column
|
|

03-31-10, 08:34
|
|
Registered User
|
|
Join Date: Mar 2010
Posts: 18
|
|
|
|
Quote:
Originally Posted by r937
like i mentioned on devshed, you have to give more information
please show the actual query that produces these results
as you know, the rows of a table do not have an inherent order, and especially not a table consisting of only one column
|
Hello r937,
Actually I don't have any working query, i was wondering that if its possible through MySQL ?
Thanks for ur reply.
|
|

03-31-10, 10:14
|
|
Resident Curmudgeon
|
|
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,606
|
|
It may be possible, depending on the problem. We may be able to answer your question once you provide more detail, but as you've asked the question so far the answer is "maybe".
-PatP
__________________
In theory, theory and practice are identical. In practice, theory and practice are unrelated.
|
|

03-31-10, 11:12
|
|
Registered User
|
|
Join Date: Dec 2007
Location: Richmond, VA
Posts: 782
|
|
The bigger question is why would the sequence matter, except when you display
Dave
|
|

04-01-10, 05:10
|
|
Registered User
|
|
Join Date: Mar 2010
Posts: 18
|
|
Hello,
Please refer the example:
Table
Andy Xyz
Bruce Xyz
Collinwood Xyz
Dragon Xyz
Zypher Xyz
Elli Xyz
Frank Xyz
As u can see, the name Zypher is not in alphabetical series.
So, can it be sorted out by using MySql query ?
Thanks

|
|

04-01-10, 05:17
|
|
Jaded Developer
|
|
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
|
|
is all you are asking is can you get rows ordered into a specific order?
if so the answer is yes... place on ORDER BY clause at the end of the select statement
if you have another sequence and you want to finds rows out of sequence then thats a different and much more complex task
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
|
|

04-01-10, 05:27
|
|
Registered User
|
|
Join Date: Mar 2010
Posts: 18
|
|
Quote:
Originally Posted by healdem
is all you are asking is can you get rows ordered into a specific order?
if so the answer is yes... place on ORDER BY clause at the end of the select statement
if you have another sequence and you want to finds rows out of sequence then thats a different and much more complex task
|
Hii Healdem.
Thanks for replying
Yaa, I am trying to finds rows which are out of sequence.
|
|

04-01-10, 06:48
|
|
Registered User
|
|
Join Date: Dec 2007
Location: Richmond, VA
Posts: 782
|
|
like i said, rows will be placed in table according to space and clustering, what difference does it make how they are put into table? and why would you need to find them? Allow the database to store the data according to its needs and you can query/order the data according to your needs.
Dave
|
|

04-01-10, 07:00
|
|
Registered User
|
|
Join Date: Mar 2010
Posts: 18
|
|
Quote:
Originally Posted by dav1mo
like i said, rows will be placed in table according to space and clustering, what difference does it make how they are put into table? and why would you need to find them? Allow the database to store the data according to its needs and you can query/order the data according to your needs.
Dave
|
Hii Dave,
The records which are alphabetically arranged are like tel. directory structure for different cities.
So it cannot be sorted in Asc/Dsc order by name, because all the cities will get merged.
keeping the record structure intact, i need to find the "out-of-sequence" records.
Thanks.
|
Last edited by andy982183; 04-01-10 at 07:10.
|

04-01-10, 07:01
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
|
|
Quote:
Originally Posted by andy982183
Yaa, I am trying to finds rows which are out of sequence.
|
good news!!! your quest is over!!!
rows in a table have no sequence (i told you this days ago)
you may now move on to your next problem
|
|

04-01-10, 09:39
|
|
Jaded Developer
|
|
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
|
|
can you identisy how a row will be out of sequence
and what cause that out of sequence condition, as others have said the way data is stored in a database is out of your control and you cannot rely on the db storing data in a specific sequence.
thats why the designers of SQL implemented the ORDER BY clause.
read da manuel as to what sort of (pardon the deliberate pun) order you want yoru rows to come in.
unless you have a really really flaky design and obtuse data source then ORDER BY should be able to do what you want
a footnote, as others have said, this forum isn't really for learning SQL from the roots, its about helping. if you are an absolute beginner then there are plenty of other sites such as w3schools. heck theres even some good books on SQL... You could always buy a copy of Rudy's (R937) book simply SQL.. in all good signatures on this forum.
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
|
|

04-02-10, 00:11
|
|
Registered User
|
|
Join Date: Mar 2004
Posts: 440
|
|
Quote:
The records which are alphabetically arranged are like tel. directory structure for different cities.
So it cannot be sorted in Asc/Dsc order by name, because all the cities will get merged.
|
MORE GOOD NEWS .... you can have more than one field in your ORDER BY clause so use
ORDER BY
city,
last name
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|