Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MYSQL


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





How Does MySQL Order Records With No ORDER BY?


If you don't specify an ORDER BY clause, how does MySQL order the records? Is it just the order in which they found in the database?




View Complete Forum Thread with Replies

Related Forum Messages:
Multiple ORDER & SUB ORDER On The Same MySQL Table
I am trying to do multiple ORDERS or SUB ORDERS on the same MySQL table, and I'm loosing my mind trying to fathom the logic and SQL statement to use, I'm no MySQL genius! more a newbie.

*** SEE ATTACHED IMAGE PLEASE

I have tried all sorts of SQL statements, e.g:

SELECT * FROM categories GROUP BY parent ORDER BY order, parent DESC

Nothing seems to work.

I think my only solution is to do a bubble-sort after putting the whole table in a PHP ARRAY ?

I'd also like the menu to act like the + pop-open sub-menu boxes on the Forum left column menu.

View Replies !
Default Order Of Records
My UserInfo table has fields timestamp(12), UserID (integer, auto_increment), UserName, PassWord, LastName, etc... 12 fields in all. I only recently added the timestamp first field, so this comment excludes that one, but...when the table consisted of only UserID, UserName, etc, I saw no ryhme or reason to the default ordering of the records in my table. I would think that they would order according to the time of their entry into the table, but the auto_incremented UID values were never in order, unless I clicked on that column heading in my db GUI to order them by UID ascending or descending.

My hosting provider appears to employ PHPMyAdmin as the GUI. Can you tell me what, if any, the default ordering mechanism is for the display of my records? Surely it's not random (and stop calling me Shirley

View Replies !
ORDER BY :: Random Records
I'm trying to have the first column (home) order by ascending while randomizing. The problem is that my second order gets affected by this as well. Is there a way I can randomize column1 while having column2 to stay put without using UNION?

ORDER BY `column1` ASC,RAND(), `column2` DESC

View Replies !
Changing The Order Of Records Being Displayed
Title might be a bit bad i suppose however this is what I have:

mysql> select mapcord,wmpcord from worldmap where (wmpcord between 'H-1' and 'H-20');

+---------+---------+
| mapcord | wmpcord |
+---------+---------+
| 8-1 | H-1 |
| 8-10 | H-10 |
| 8-11 | H-11 |
| 8-12 | H-12 |
| 8-13 | H-13 |
| 8-14 | H-14 |
| 8-15 | H-15 |
| 8-16 | H-16 |
| 8-17 | H-17 |
| 8-18 | H-18 |
| 8-19 | H-19 |
| 8-2 | H-2 |
| 8-20 | H-20 |
+---------+---------+
13 rows in set (0.01 sec)

and this is what i want it to do:
+---------+---------+
| mapcord | wmpcord |
+---------+---------+
| 8-1 | H-1 |
| 8-2 | H-2 |
| 8-3 | H-3 |
| 8-4 | H-4 |
| 8-5 | H-5 |
| 8-6 | H-6 |
| 8-7 | H-7 |
| 8-8 | H-8 |
| 8-9 | H-9 |
| 8-10 | H-10 |
| 8-11 | H-11 |
| 8-12 | H-12 |
| 8-13 | H-13 |
...etc,etc,etc,etc
+---------+---------+

View Replies !
Limiting Number Of Records & Specifying Order
I have a table of results, including resultNumber and resultDate as fields.

I want to retrieve the 25 most recent (by date) records ordered in ascending date order.

So if for a particular user there are 50 results, I want to get the most recent 25 in ascending date order.

I thought the answer was a subquery with a ORDER BY resultsDate DESC LIMIT 25 on the inner query and an ORDER BY resultsDate ASC on the outer query, but I get an error message saying not supported in MySQL 4.1.22 which my ISP has.

View Replies !
Order Records Based On Two Columns
I'm working on PM feature for my site. So far I have this table:

+-----------------+-----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+-----------+------+-----+---------+----------------+
| ID | int(11) | NO | PRI | NULL | auto_increment |
| subject | char(100) | YES | | NULL | |
| body | blob | YES | | NULL | |
| r_id | int(11) | YES | | NULL | |
| s_id | int(11) | YES | | NULL | |
| date_sent | int(11) | YES | | NULL | |
| date_read | int(11) | YES | | 0 | |
| r_date_to_trash | int(11) | YES | | NULL | |
| s_date_to_trash | int(11) | YES | | NULL | |
| r_status | int(11) | YES | | NULL | |
| s_status | int(11) | YES | | NULL | |
+-----------------+-----------+------+-----+---------+----------------+

r_id - "Receiver's ID"
s_id - "Sender's ID"
r_date_to_trash - "Unix timestamp when receiver deletes the message"
s_date_to_trash - "Unix timestamp when sender deletes the messages"
r_status - "receivers msg status, if r_status == 1 then message is in the trash
s_status - "senders msg status, if s_status == 1 then message is in the trash

So this is the query I have right now:
SELECT * FROM pm WHERE (r_id = 1 AND r_status = 1) OR (s_id = 1 AND s_status = 1)

This is the result:
+-----+------+------+-----------------+-----------------+----------+----------+
| ID | r_id | s_id | r_date_to_trash | s_date_to_trash | r_status | s_status |
+-----+------+------+-----------------+-----------------+----------+----------+
| 104 | 1 | 2 | 1226972079 | NULL | 1 | 0 |
| 110 | 1 | 2 | 1226971762 | NULL | 1 | 0 |
| 111 | 1 | 2 | 1226971891 | NULL | 1 | 0 |
| 112 | 1 | 2 | 1226972033 | NULL | 1 | 0 |
| 113 | 1 | 2 | 1226972462 | NULL | 1 | 0 |
| 120 | 2 | 1 | 0 | 1227103836 | 0 | 1 |
| 122 | 2 | 1 | 0 | 1227103841 | 0 | 1 |
| 127 | 2 | 1 | 1226972346 | 1226972090 | 1 | 1 |
| 128 | 2 | 1 | 0 | 1226972095 | 0 | 1 |
| 129 | 2 | 1 | 0 | 1226972176 | 0 | 1 |
| 130 | 2 | 1 | 0 | 1226972396 | 0 | 1 |
+-----+------+------+-----------------+-----------------+----------+----------+

This is the problem:
I'm trying to list the messages that are in the trash in order by date they were deleted (r_date_to_trash, s_date_to_trash). I need to join these two fields somehow together and then I could just do ORDER BY whatever DESC. That way the messages in the trash will show up in the order they are deleted.

View Replies !
Listing Records In Exact Order
On this query:

SELECT * FROM articles WHERE id IN(1, 100, 50, 200)

Is there a way to make the rows return on the exact order I asked for them (1-100-50-200) instead of their position on the table or some custom ORDER BY?

View Replies !
Limit ORDER BY RAND() To A Range Of Records?
trying to get a range of records randomly ordered. For example if I want the records from 0 to 10 from MyRecords I would get 1,3,4,2,5,6,8,10,9,7 and another time I would get 7,10,6,1,4,3,8,2,9,5. I have tried "SELECT * FROM MyRecords ORDER BY RAND() LIMIT 0,10" but I keep getting records from the whole record set, not from records 0 to 10.

View Replies !
How Do I SELECT Records From A Database In Alphabetical Order
how to SELECT records from a database in alphabetical order,

View Replies !
Limit On Select Produces Records Out Of Order
I have a Java applet that displays descriptions (from an sql table) in a text area. The latest description is shown on load-up with max(time) ok, and there is a button to step through them in reverse order from latest to earliest.

I have a problem with the following query:

SELECT idescription FROM descriptions where unit = 'A' and iname = 'plate' order by 'time' limit "+nextrecord+",1

This query is executed on a java button press. The variable 'nextrecord' has already been set to 1 (to get the second latest, i.e. 'very useful item') and then 1 is added to it each time the button is pressed to get the next previous one. But the resulting order is squiffy, e.g. when applyed to the following table Code:

View Replies !
Re-order The Natural Order Of All Of All The Rows Of A Table
Basically I want to re-order the rows of my entire database. It has many thousands of rows, and people are constantly running the same query against it. The problem is its quite slow (using a shared host).

I know you can use an sql query to order by column, however I need to re-order twice and it really seems to be slow due to this.

Since the query is always the same, if the rows were already ordered in the database , then the ordering query wouldn’t need to be done.

Is there an easy way to do this, without deleting each and every row, then inserting them again?

basically in the database I have:

The natural order when you do a select * from this table (without using an order by query):
________________________
|cola |col.. |coln |
|dataA |dataB |dataC |
|dataX |dataY |dataZ |
|datal |datam |datan |

(obviously a lot bigger than this) and I want reorder the entire table , eg

The natural order when you do a select * from this table:
________________________
|cola |col.. |coln |
|dataA |dataB |dataC |
|datal |datam |datan |
|dataX |dataY |dataZ |

So is there an easy way to do this, am I just being dumb?
or do I need to delete the entire table and insert the rows one at a time in order?

View Replies !
How To ORDER BY DESC Properly. It Makes 150 Before 50 If ASC Order!?
I have this list:
50
150
200
250
300
350
400
450
500

If I order it by ASC order then mysql results this:
150
200
250
300
350
400
450
50
500

What the hell ?? How do I order it properly?

View Replies !
ORDER BY WHERE + Include Rest Of Table Or ORDER? Possible?
I need to create some SQL that when run returns all the rows which a column is equal to number that has been specified, but then the query needs to return the rest of the rows in the table. How could this be done? is it even possible? Is their order syntax that could do this better?

View Replies !
Order Then Order Again But From Colums Of Different Tables
I'm a noob to sql and I've been using a query thats worked really well for me for some time, but now I need to optimise it a little further and things seem to be coming un-done

its used for a search query: .....

View Replies !
How To ORDER BY The Order Requested In The Query?
Here's my query:

SELECT * FROM myTable WHERE id=14 OR id=3 OR id=8

Simple stuff, I know. The result of the query is three rows that are all sorted by their 'id' in ascending order. I don't want this. What I want returned are rows sorted by the order in which I requested them. I need the query to return row #14, #3 and then #8 in that order.

View Replies !
Order By - Order Of Precedence?
I know how to use the order by, but wondered if there is an order of precedence in using it.

Facts: hcounty is a county that someone puts in a home county in which they live. In the comments they are also allowed to put text, that might contain a county listing also. I want to have the results put the records that have hcounty matches first, then the records that have a county match in the comments field after the first set of records. I have tried all sorts of order by and group by and can't get the result I'm looking for....

View Replies !
ORDER BY :: Sequence Order
Is it possible to ORDER BY based on the sequence order, for instance I use this Query:

SELECT * FROM Showroom WHERE Artnumber IN (52900, 52536, 52730)

the result is this:

Artnumber Price
52536 25,80
52730 1,90
52900 31,10

View Replies !
Order By Unconventional Order
How can I have letter "z" comes before letter "a" when I select my items from a table. I need my list to show (z, a, b, c, d, ...).

Also, how can I have numbers come after letters, say, if I want my list to be ( z, a, b, c, ... 1, 2, 3, ...)

View Replies !
ORDER BY Out Of Order - Fixed
I have a query that uses two tables that I want to produce output like the following:

+-------------+-------------+-----------+
| LOCATION | GROSS SALES | NET SALES |
+-------------+-------------+-----------+
| Location 1 | 11,860,735 | 2,907,552 |
| Location 4 | 4,814,029 | 1,077,003 |
| Location 3 | 2,711,795 | 710,804 |
| Location 5 | 2,660,040 | 666,255 |
| Location 2 | 2,049,470 | 563,830 |
| Location 8 | 2,227,730 | 543,220 |
| Location 7 | 1,766,880 | 425,483 |
| Location 6 | 1,721,681 | 367,252 |
| Location 10 | 13,424 | 2,253 |
+-------------+-------------+-----------+

However, I cannot get the "order by" part of the statement to work. I have tried adding a zero to the order by alias. And when I attempt to specify the field in the order by with the calculation and not the alias I get an error.

The following examples are queries without the zero and with a zero added to the alias in the order by line. I have also added the details for the table below for reference. Code:

View Replies !
Custom Order For ORDER BY
I'm grabbing six specific records, like so:

$result = mysql_query("SELECT * FROM casestudies WHERE id=1 OR id=2 OR id=3 OR id=4 OR id=5 OR id=6 ORDER BY ___________",$db);

I'd like to post them in a custom order, specifically: 1,3,4,5,6,2. Can't figure out how to do this with ORDER BY, if that's even possible. Anything I'm missing?

View Replies !
Force Order By Order??
I have 6 rows of data... each has a name, eg: c1, c2, mrgs1, totalfte.
they are all under the one column "field". Is there a way I can force their order??

at the mo, I use "ORDER BY field DESC" and its coming out lile

mrgs1, totalfte, c1, c2

I need

totalfte, mrgs1, c1, c2

is it possible to sort like this??

View Replies !
Order By Ascending Order
I have a mysql table with a column with a few zero values and an ordered list of numbers.. eg 0,0,0,1,2,3,4,5

is there a way to order the table in ascending order for the numbers 1-5 then display the ones with zero afterwards in one sql query..

so it would turn out like 1,2,3,4,5,0,0,0

View Replies !
How To Query Records That Have Same Words But Maybe Different Words Order?
I am trying to find a way to do a select query that can find records that have same words in any orders. e.g. "hello good morning", "good hello morning", "morning good hello"... they should all returned by the select query.

Please don't tell me that I can use "or" inside select query. It's because what if the string has 10 words? There are tons of permutations.

View Replies !
MySQL Order
I would like to order the results from a query in a non standard way.
I would like to order them by a field called season and return the
results in the order LOW, MID, HIGH.
I obviously can't order the results alphabetically but wondered whether
you can define the order in the query.

View Replies !
MySQL 4.1.9 ORDER BY
I've a problem with a SELECT in LINUX S.O.. When I execute this SELECT in Windows Operating Syetem the SELECT work OK but don't work correctly in Linux operating system. MySQL versión is 4.1.9 in both computers.

The problem is that this SELECT dom't order correctly by Precio_INM (Linux Computer S.O.)

The original Select is this :

(SELECT * FROM inmuebles LEFT JOIN municipios ON inmuebles.Poblacion_INM = municipios.CP_MUN LEFT JOIN agencias ON inmuebles.IDAGE_INM = agencias.ID_AGE
WHERE foto1 != '' AND Activo_INM != 'N' AND (Pack_AGE = 'P-100' OR Pack_AGE = 'P-50')
ORDER BY Precio_INM ASC)
UNION ALL
(SELECT * FROM inmuebles LEFT JOIN municipios ON inmuebles.Poblacion_INM = municipios.CP_MUN LEFT JOIN agencias ON inmuebles.IDAGE_INM = agencias.ID_AGE
WHERE foto1 != '' AND Activo_INM != 'N' AND Pack_AGE = 'P-20'
ORDER BY Precio_INM ASC) LIMIT 0, 10

View Replies !
Help With MySQL Order By
I have several rows in my database with a field called "package" that can be either 1, 2 or 3. I want to order the results by this field but only so rows with a package of 1 are returned first. Rows with a package of 2 or 3 should be displayed in any order below this.

I realise I can achieve this with 2 queries however my current query contains quite a few joins etc and there would be a lot of unnecessary replication.

View Replies !
MySQL, Order By IN ()
There are three rows in the table (MySQL):
id text
1 aaa
2 bbb
3 ccc

PHP Code:
$query = "SELECT id, text FROM table WHERE id IN (2,3,1)"
$result = mysql_query($query);
 
while(list($id, $name) = mysql_fetch_row($result))
    echo "$id - $name<br />";
It prints
1 aaa
2 bbb
3 ccc

but not as I want
2 bbb
3 ccc
1 aaa

Is there a way to make it prints in the order of "id IN (2,3,1)" and not by "ORDER BY id" ?

View Replies !
MySQL Order By Problem
When i ORDER names containing characters like â or ê it places
them behind all other a's or e's. So instead of Aaron, Aâst, Abces, i
get Aaron, Abces, Aâst. Does anyone know a solution to my problem ?

View Replies !
Order Of Mysql Columns
Is it possible to alter the order that mysql columns are held within the database? I have some large tables with columns that I have recently added. I'd like these to be grouped with similar data.

View Replies !
MySQL Order Results
Does anyone know how MySQL orders the results it returns when no ORDER BY is specified in the query?

View Replies !
Php/mysql Order By Date
i am trying to select ID, date, and title of my blog and sorting the results by date. apparently it's giving me this error: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /web/index.php on line 57

when i take out ORDER BY post_date, the php runs perfectly. post_date's data type is datetime in mysql. below is the code;

mysql_pconnect('host','user','pass');
mysql_select_db('db');

$sideResults = mysql_query("SELECT ID,DATE_FORMAT(post_date,'%m.%d.%Y') sideblogDate,post_title FROM wp_posts LIMIT 8 ORDER BY post_date");

$sideRowRight = mysql_fetch_assoc($sideResults);

echo "<ul>";
do{
?>

html codes ... html codes ... html codes ...

<?php
}while ($sideRowRight = mysql_fetch_assoc($sideResults));
echo "</ul>";

any ideas?

View Replies !
Mysql Order By Issue
I was with a problem with order by clause, sample:

CREATE TABLE CLIENT (ID INT(3) NOT NULL AUTO_INCREMENT,
NAME VARCHAR(15),
PRIMARY KEY(ID)
);

CREATE TABLE CLIENT_MAIL(IDMAIL INT(3) NOT NULL AUTO_INCREMENT,
ID INT(3) NOT NULL,
MAIL VARCHAR(15),
PRIMARY KEY(IDMAIL) );


INSERT INTO CLIENT VALUES (NULL,'A');
INSERT INTO CLIENT VALUES (NULL,'B');

INSERT INTO CLIENT_MAIL VALUES (NULL,1,'A');
INSERT INTO CLIENT_MAIL VALUES (NULL,1,'B');

INSERT INTO CLIENT_MAIL VALUES (NULL,2,'D');
INSERT INTO CLIENT_MAIL VALUES (NULL,2,'F');

INSERT INTO CLIENT_MAIL VALUES (NULL,2,'C');

and one query:

SELECT CLIENT.ID,CLIENT_MAIL.ID,CLIENT.NAME,CLIENT_MAIL.MAIL FROM CLIENT,CLIENT_MAIL WHERE CLIENT.ID=CLIENT_MAIL.ID ORDER BY CLIENT.NAME,CLIENT_MAIL.MAIL DESC;

show is:

+----+----+------+------+
| ID | ID | NAME | MAIL |
+----+----+------+------+
| 1 | 1 | A | B |
| 1 | 1 | A | A |
| 2 | 2 | B | F |
| 2 | 2 | B | D |
| 2 | 2 | B | C |
+----+----+------+------+

in resume i need show the result

NAME MAIL
B F
B D
B C
A B
A A



View Replies !
Mysql Messes Up ORDER BY Optimisation?
I have a pretty long query that ends with

ORDER BY R.r_recent_hits DESC LIMIT 0, 1

I also have an index on R.r_recent_hits. I did an explain select and
got this:

ALL - which means (from the manual):

A full table scan will be done for each combination of rows from the
previous tables. This is normally not good if the table is the first
table not marked const, and usually very bad in all other cases.

My question is, why in the world would MySql choose to do this type of
join when there is a perfectly good index there! And I have run analyse
on all of the tables.

It seems like it would be a no-brainer, as soon as the optimizer sees
ORDER BY, just use the given index for that column, that will get you
the highest value easily. Does any one know why it would not
automatically do that? The query essentially does nothing but selects
the highest value. If i suggest what index to use by saying USE INDEX,
it works fine. But, I don't think i should have to.

if you are interested, here is the query:

EXPLAIN SELECT H.accumulated_hits, R.num_messages, R.r_recent_hits,
T.topic_scope, R.thread_id, U.username, U.user_id, T.title,
UNIX_TIMESTAMP(T.post_time) AS post_time, T.topic_id, T.description FROM
threads as R, topics AS T , users AS U, hit_counter AS H WHERE
T.topic_id=R.topic_id AND H.object_type='THREAD' AND
H.object_id=R.thread_id AND U.user_id=T.user_id ORDER BY R.r_recent_hits
DESC LIMIT 0, 1

View Replies !
MySQL Order By Average Of Two Fields
I have made a Toplist mod for vBulletin, and it currently has a setting to choose to rank the sites by their in hits, or their out hits. I would like to add another setting that can rank them by the average of the in and out hits for each of the sites in the Toplist. Does anyone know how I can have MySQL order them by the average of those two fields?

View Replies !
Mysql Dump Table Order
How does mysql order the tables in the file that it creates? Is is it by the order the tables were created, by alphabetic order? can I specify an order by giving the table names in the command line?

View Replies !
List Return Order From MySql
If I have a drop down list query do I get it to return th eorder in the mysql structure or the php code?

Example. I want this list to come back to the list by the VALUES (1, 'Alabama');, VALUES (2, 'Alaska'); etc. It's coming back alphabetically. Thanks.

CREATE TABLE `sbcl_us_states` (
`sb_id` bigint(20) NOT NULL auto_increment,
`sb_state` varchar(255) default NULL,
PRIMARY KEY (`sb_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=52 ;
--
-- Dumping data for table `sbcl_us_states`
--
INSERT INTO `sbcl_us_states` VALUES (1, 'Alabama');
INSERT INTO `sbcl_us_states` VALUES (2, 'Alaska');

View Replies !
MySQL Inserting Rows Out Of Order
Using PHP, I generated a query file that has several thousand INSERT statements in it. The problem is that when I run the INSERT query, the rows are NOT added to the table in the order in which they occur in the SQL file. The first few hundred INSERTS are inserted toward the end of the table.

What is the problem?

The way around this is for me to resort the table based on one of the columns so the proper order is maintained. I'm using this with forum software, so it is critical that the table be in order else my boards are out of order.

Is there a problem with MySQL or with me? Any ideas why rows would be added out of order?

View Replies !
Multiple Order By Not Working In MySQL
I'm trying to do a query with two columns for the order by, but the second column is being ignored. I've tried adding asc and desc to it but there's no difference, it's as if the competitorID isn't even there.

select * from table where clientID = 15 order by dateAdded desc, competitorID;

View Replies !
Speed Up Order Table Table-name Order By Col-name For Large Table?
I have a table with 2 column: id and name. Column name is of type varchar(100).
The table has about 0.1 billion rows, taking 11G disk space.

Now what I want to do is alter the table by the name column. I ran the command: "order table table-name order by name"

1).Firstly, it create tmp table,which takes 19G disk space.

2).After that,the 19G space seems to be released(I see the free disk space increase by "df").

3).Then I see that in the mysql directory, the size of the mysql file #sql-14f7-2.MYD" increases 2M every time, but very slow. I guess this mysql file is the new table after order. But how can it be so slow? It only increase 2M every 2 minutes or so, which would takes weeks to finish the command.

So could any one tell me how can I speed up this command? Are there any variables I can adjust to make this faster?

View Replies !
MySQL Order By Title, But Remove 'The', 'A', 'An'
I have a bunch of titles in a database and I want to have mysql select them all and place them in alphabetical order.

The only problem is that some titles start with the, a, and 'an', which obviously need to be accounted for. Is there a way to tell the query to avoid 'the', 'a' and 'an' in order to alphabetize properly?

View Replies !
Configuration Of MySQL - ORDER BY Clause Problems
Edit:
Solved! Single quotes around the column name were the problem... red herring... didn't spawn an error, probably because single quotes would be valid for an alias?

Anyway, for reference there must be a MySQL setting that tells MySQL to ignore the single quotes in an ORDER BY clause and call the column if there's no matching alias. If anyone knows what *that* setting is, I'm still interested...

I'm stumped! A simple PHP application with a filter using ORDER BY has been moved from a remote server on to a local Debian (Etch) machine running XAMPP. On the remote server it worked fine. On the local server the ORDER BY is ignored. It looks like this:

SELECT *
FROM contacts
WHERE Forenames REGEXP '^{name}'
ORDER BY '{column_name}'
Where {name} is user entered data and {column_name} is determined by which column header in the returned data was clicked in the interface. For example:

SELECT *
FROM contacts
WHERE Forenames REGEXP '^Jake'
ORDER BY 'Company'
As I say, this *was* fine... but now on the local machine the ORDER BY is totally ignored by MySQL. I know the problem is with MySQL because I get the same result in the MySQL Query Analyser, so it's not a PHP/Apache issue.

Is there a config option for switching ORDER BY on/off like there is in MS Access? I'm 99% sure this is a MySQL config problem...


View Replies !
Changing Order Of Columns Using Mysql Query Browser
I have a table that is already created and I wanted to add a column, but put it somewhere in the middle of the table. is there a drag and drop (or something just as easy) method to move it up in the table? or do I have to re-create the whole table?

View Replies !
Order By Count Of Occurrences In 2nd Table Without Nested Query (MySQL 4.0.27 Workaround)
My ISP is using an old version of MySQL, 4.0.27-max-log. I am using a query that runs fine on my test-server (MySQL 5.0.70-log). The main point of this query is to return an ordered list of volunteers for job assignment. One of the metrics is the number appearances in an activity table. I am using a nested query to COUNT the number of appearances during a specific time window to obtain this metric, but this approach does not appear to work in 4.0.27.

Is there a simpler or alternative query that will make 4.0.27 happy?

SELECT job10.person_id, people.history, job10.history, (

SELECT COUNT( * ) FROM activity WHERE activity.person_id = people.person_id AND (activity.day = '2009-2-1' OR activity.day = DATE_ADD( '2009-2-1', INTERVAL 3 DAY))

) AS appearances, CONCAT( first_name, ' ', last_name ) AS name
FROM duty_sing_am INNER JOIN duty_people USING ( person_id )
WHERE people.active AND job10.willingness > 0
ORDER BY appearances, job10.history, people.history, job10.person_id

View Replies !
Order Of MySQL Results - Same As In MySQL DB?
I've got a MySQL database with some data in it. I can retrieve and display data with no problem. My question is, is the order in which results are returned (WITHOUT using the ORDER BY clause) necessarily the same order in which the information is entered into the database?

So without using ORDER BY, will results from the query be in the same order as they are in the actual DB?

View Replies !
ORDER BY A Set
I want to order a result set by a specific order, rather than just ascending or descending alphabetically/numerically. For example if I have a table called region

idName
1London
2Scotland
3Wales
4Midlands
..
..
..

but I want them ordered so that the result is Scotland, London, Wales,
Midlands,... can I use some sort of set in the order by clause?

Something like:
select name from region order by id {2,1,3,4};

I haven't used mysql SETs before so not sure if they can be applied here.

View Replies !
Order By Str To Int
Hi jave a database and I want to oder my result by a colum containing
string bit order them like they where int

ex Select * form members order by level

level is string containing data like '12'

I want to oder like the level is Int 12 and not string '12'

View Replies !
Order By OR
Lets say I have a query similar to:

SELECT * FROM company WHERE id='3' OR id='1' OR id='7' ;

I want to be able to get the results to come out ordered by the order
the ids were searched (the sequence in the WHERE OR; 3 first then 1,
then 7.), so the results would be like:

Row | id| name
-------------------
0| 3| Joe's Co
1| 1| Buymart
2| 7| The big evil

As it is the results returns it like id 1, then 3, and 7.

View Replies !
Row Order
If I run a simple SELECT on a single table and it returns a small sized data set of say a hundred rows or so, and I don't set any ordering constrints (such as order by date or ID or something), if I run this same query over and over, will the row order be the same assuming no changes in the table?

View Replies !
Specify Order
Is it possible to specify order before grouping?
I want to group a list of user actions by user id with the most recent at the top. For example, the query would be:
SELECT * FROM UserActions ORDER BY Time DESC GROUP BY UserID;
That doesn't work because you have to specify GROUP BY before ORDER BY. However, the output of specifying them in the correct order is not what I want. It seems to pick the first record in the database as the GROUP instead of the most recent one.What I'm actually trying to do is get a list of all the Users in order of the most recent UserAction, so as to be able to view the latest acitivity on my web site.

View Replies !
Sql Order By
I have just started re-writing my forum, which is going to take a long time. While I am doing this I have a bug to solve on version 1.3, which is to do with the SQL order by.

Each post has a number, 1, 2, ect. Every time a post is added the post number increases.

When I get to 10, the ORDER BY section of my script ( I assume ) uses the first number before any others. So 10 is considered less than 2. Ruining the whole order by system.
Is there a way that this can be solved???

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved