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.





[Default] Order


I have a MySQL database with a table that I assumed "by default" would insert records in chronological order - i.e. just add each record to the end of the table. What is happening however is that 'some' records are inserted just somewhere in the file - not at the end of the table. I can tell this because there is a date field in the table.
How do records get added to a database? by key, index, ????
Is there some way to force a record to be added to the bottom of the table?

Key info about the table:
. there is not a primary key.
. there are 3 index's




View Complete Forum Thread with Replies

Related Forum Messages:
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 !
Default Order Of Rows
when fetching rows from mysql, what defines the default order they will be returned in? or is the default order undefined?

for example, lets say my simple table has 3 rows.
row 1 was inserted first
row 2 was inserted second
row 3 was inserted third

if i used the following query, notice no order by clause:
select * from mytable

would they always be returned in the order they were inserted in?
is there anything that could cause them to not be returned in the order they were inserted in(aside from an order by clause).

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 !
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 !
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 !
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 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 !
Specifying Default ''
does specifying default make the table smaller, like

setting_title varchar(32) NOT NULL default '',

instead of
setting_title varchar(32) NOT NULL,
make the entire row smaller, instead of a blank 32?

View Replies !
Bad? Id Int(11) DEFAULT '0'
I'm trying to install the authlib module that's required for the open-source iOutliner web-based outliner (http://ioutliner.com), but it fails halfway through when creating the tables:

//Bad! /* SQL Error: Invalid default value for 'id' */
$query = mysql_query("CREATE TABLE authlib_data (
id int(11) DEFAULT '0' NOT NULL auto_increment,
name text NOT NULL,
email text NOT NULL,
age int(3) DEFAULT '0' NOT NULL,
sex text NOT NULL,
school text NOT NULL,
PRIMARY KEY (id)
)");

//Bad! /* SQL Error: Invalid default value for 'id' */
$query = mysql_query("CREATE TABLE authlib_login (
id int(11) DEFAULT '0' NOT NULL auto_increment,
username text NOT NULL,
password text NOT NULL,
PRIMARY KEY (id)
)");

According to Google, DEFAULT '(0)' seems a legit instruction. What's wrong with this?

View Replies !
DD-MM-YYY As Default?
The Mysql receive dates like "YYYY-MM-DD", there is a way to turn that to "DD-MM-YYY" as default.

View Replies !
Default Date??
I have a field (called active) of type DATE and I want to add a default value. The default value must be the current date. Is this possible to do this in the table create statement?

CREATE TABLE mytable
(
id INTEGER NOT NULL AUTO_INCREMENT,
active DATE DEFAULT ?????,
PRIMARY KEY (id),
)

View Replies !
Default Permissions
This is a fairly simple question but I'm new to mySQL. To log on to
mySQL I need to type at the prompt:

mysql --user='username' --password='password'

as opposed to just typing mysql and being recognized without having to type identification. Anyone know how I can change this?

View Replies !
Column Default Value
How may I change the default value of
an existing table?
(type will remain the same)

View Replies !
When To Use NULL As Default Value
I pretty much set a fields default value to NULL if it not a "required" field in my app.

View Replies !
Default Peramaters
If I have a colum of timestamp, can I set the default as now() do I need a ;
at the end or what?

View Replies !
Timestamp Default Value
I am using:
mysql Ver 12.22 Distrib 4.0.18, for sun-solaris2.9 (sparc)
And I do this:

mysql> create table test (a timestamp default null, b timestamp default null);
Query OK, 0 rows affected (0.03 sec)

mysql> desc test;
+-------+---------------+------+-----+----------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------------+------+-----+----------------+-------+
| a | timestamp(14) | YES | | NULL | |
| b | timestamp(14) | YES | | 00000000000000 | |
+-------+---------------+------+-----+----------------+-------+
2 rows in set (0.00 sec)
Can anyone tell my why the default value for column 'b' is not NULL as well?

View Replies !
Changing A Default Value
i have a column that originally assigned a default integer value (1) to a column that contains about 1000 records. now, i'd like to replace all those with an incremented value. i figured out how to change it so newly added data is incremented, but cant seem to figure out the command to go back and change all data from the beginning so that it is now incremented.

View Replies !
MySQL Default Value
When a customer places an order, the database sets the default at "3" which means "not complete" when it is complete and billed, It is assigned a "1"

I want to have it be assigned a new number on all future orders, but no not want it to go back and reset every single past order. If I change the default value number in the database, will it only apply to new orders, or will it change every single record to the new default regardless of their current status?

View Replies !
Set Default Collation
However I recently tried MySQL 4.1.x and noticed that there have been some changes. My questions are:-

1) The default collation setting is Latin1_swedish_ci. What do I need to change this to in order for my old tables to import correctly? Currently special chars like tm <- trademark import as ? <-Question Marks?

2) How do I set my own default?

3) Is there any way to export a new database back to an old version of MySQL eg 4.1.x -> 4.0.x?

View Replies !
Default Character Set
I have a problem with character set client and connection. I have all tables in cp1250_czech_cs collation and I have set a global session character_set_client, character_set_connection and character_set_result to cp1250. When I make a connection to the database in PHP (mysqli_connect()) and execute a query SHOW SESSION VARIABLES; it return that character_set_client, character_set_connection and character_set_client is set to latin1.
What can I do, when I want to set this variables to cp1250 as default? (and not use SET NAMES cp1250; in each script).

View Replies !
Field Default Value
This may have already been asked. But I couldn't find anything. (Maybe I am asking the wrong question).How do I find out the default value of a field using php? Something similar to mysql_field_name() or something.

View Replies !
Overriding Default
Can I change the default minimum length of words in Fulltext Search without having to ask my web hosting company to do it? I mean, change the value using through PHP script?

View Replies !
Timestampt Default
When I create a timestamp field in phpmyadmin it's default is always 000-00-00 00:00:00 instead of just a number. Anyone know why and how to change this? I tried deleting the default but when I hit save it puts it back in.

View Replies !
Default Field
There is a table, with some fields including an auto_increment field, some more integer type, text,varchar etc type of fields.
2. I am trying "SELECT * FROM myTable" [No ORDER BY clause used]

question:
Which field will be used by default, for ordering the records?
Will it be the primary key(which is auto_increment) always?

View Replies !
Default Autocommit=0?
Is there any way I can set up mysql client so that the default value for autocommit is 0? This is for when I'm running the command line client on linux/windows or the Query Browser on windows. I would feel much more comfortable that I'm not going to accidentally put in the wrong where clause and update or delete a bunch of records. I like to use the number of rows affected by my query as a double-check that I've done what I intended to do, and then commit it.

I've searched around but could not find any mention of this issue -- all of the postings on autocommit that I found have to do with accessing mysqlserver from a program such as java or PHP.

View Replies !
DEFAULT DATE
I need a sistem variable for get the actual date when I create a table.

I use sysdate in Oracle and it works, but i have not idea about mysql.

I want to use into a create table like this:

CREATE TABLE users(
id_user int PRIMARY KEY,
registrationday date DEFAULT sysdate
);

View Replies !
How Set Default To CURRENT_TIMESTAMP?
I have a column of type datetime which I would like to have a default value of CURRENT_TIMESTAMP. I have tried:

ALTER TABLE table1 ALTER dateEntered SET DEFAULT CURRENT_TIMESTAMP

but this gives a syntax error, probably because it wants a literal at the end there.

View Replies !
Default Value For Date
CREATE TABLE ...
`birthdate` DATE DEFAULT CURRENT_DATE(),
...
doesn't work - produces syntax error.
Anybody know how to declare current date as the default value for a DATE column?

View Replies !
DATE DEFAULT ...
If I want to use date for my column and I want to set a default for it what do I specify? I know for timestamp I can use current_timestamp but what do I use for date?

View Replies !
DATETIME - Set Default Value
I have a database table (MYSQL v5.0.67) in which I store several date fields. I have set these all to be not null and to have a default value of '0000-00-00 00:00:00' e.g.

`last_login` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',

However when I run my create database script (generated from a schema design in MYSQL Workbench) it complains as follows:

Error Code : 1067
Invalid default value for 'last_login'

I leave it as nullable with no default value and run the script to create the table which works fine. I can then use a tool like SQLyog to alter the table generated and set this to be not null with a default of 0000-00-00 00:00:00 and it is happy to alter the table. Obviously this is not ideal and it should work straight from the script.

View Replies !
What Is Default Database Name
I want to specify access options for MySQL. Please tell what is MySQL hostname, MySQL username, MySQL passoward & MySQL database name for the connection to the MySQL server.

View Replies !
Select Default Value
two tables:
master_table (
id int not null,
work_id int not null,
sub_work_id int not null,
primary key(id)
)

ref_table (
id int not null,
work_id int not null,
sub_work_id int null,
name varchar(20),
primary key(id)
)

View Replies !
Use Now() As Default Value For A Column
I cannot find any good material on this, and it seems like it should be so easy.

I have two columns in my table, creation_date and last_modified_date. I want the creation_date field to bear the default value of Now(), so that when a row is created the timestamp is there. This value should never change, and should only be set on row creation.

The last_modified_date field I want to change on the UPDATE only.

It seems that this may be possible using the TIMESTAMP type and the default values there but what I read is that they will update everytime a row is altered.

This would be dead-simple if I could just specify Now() as the default value.

View Replies !
Default Value Is Not Set After Upgrade To 5.1
I try to update a column which is defined as tinyint(3) unsigned NOT NULL DEFAULT '0' by setting it to NULL. But instead of setting the column to the default value like it is explained in the documentation, the statement failed..

View Replies !
How Do I Set A Default Date Value
I have tried putting in now() via phpmyadmin as the default value and my new record entries return a value of '0000-00-00'. My purpose is to have a default created_date of the time mySql writes each new row.

View Replies !
Default Delimiter Not Set
No query specified.

The only way to end it was CTRL+C. Using g and G work normally, and if I manually type "DELIMITER ;", then I can use the semicolon just fine (until I log out and back in again.)

Is there some configure option I need to use to make sure the semicolon is the default delimiter?

View Replies !
Default Block_size
I would like to ask what would be the default block_size in mysql 5.1.33. Just like in oracle, the block_size may vary or depend on the OS block_size.

Is the block_size in mysql same with each storage engines.

View Replies !
NOT NULLs With Default
I'm cleaning up a database but I see this all over the MySQL world. I understand that having defaults speeds things up. But what I don't understand is why someone would make a field NOT NULL and then put a null default in it? This makes no sense to me at all. Is this the fault of using phpMyAdmin to create tables?

Here's a sample:
CREATE TABLE `listnames` (
`id` int(11) NOT NULL auto_increment,
`list_name` char(30) NOT NULL default '',
`display_name` char(100) NOT NULL default '',
`active` char(3) NOT NULL default '',
`last_modified` timestamp(14) NOT NULL,
UNIQUE KEY `id` (`id`)
)

Ok, so you don't want NULLs in your data but there is no default. It's very likely that the data will be wildly differently. So setting a default makes no sense -- or does it?
I don't want to drop the default '' if it makes sense & I'm just not getting it.

View Replies !
Default Value For A Column, When Value Is Not Specified
We have migrated our database from DB2 to MYSQL. In DB2, there is an option like 'GENERATED BY DEFAULT AS IDENTITY' which will cause DB2 to generate unique values for the identity column during insert operations if no value is specified for the identity column. However, if a value is specified for the identity column, DB2 will use it in the insert operation.

In MYSQL, is there an option like this?

View Replies !
Default Value On A Column
Hey guys, my hope is to quickly move from SQL2005 to mySQL and i'm hitting the GUID roadblock. If mySQL can't do a GUID by default on a column, I've got to rewrite a ton of my application around that. Tell me with 5.0 this is possible now? Or that there's some cool work-around?

View Replies !
DATETIME DEFAULT Now().
I would like to know in what way, I can set the default value of a DATETIME field to Now() so I don't need to put the code in my scripts.

ALTER TABLE `tbltest` CHANGE `TheDate` `TheDate` DATETIME DEFAULT 'Now()'

With the ' ' it doesn't error, but it's probibly just sending the string "Now()" and I get the default date 0000-00-00.
If I take off the ' ' I get an error.

Anyone know a way I can set my default value for my DATETIME field to automatically insert the date and time with each new record?

View Replies !
Get Column's Default Value?
How can I find out the default value of a column, by using PHP? Is there a special query for this?

View Replies !
NULL Default Value
I have a simple table. I'm using phpmyadmin. As you can see my default values for NULL are 0 but for some reason wen a null value is posted to the database it appears as "NULL" instead of "0"....

View Replies !

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