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.





Order By Having No Affect


I have the following query:

SELECT a.awardId, a.linkId, a.award, a.awardDate, a.dateCreated, a.dateModified, a.orderBy, c.pageTitle, u.username
FROM lnk_content_awards as a
INNER JOIN tbl_links as l ON a.linkId = l.linkId
INNER JOIN tbl_content as c ON l.contentId = c.contentId
INNER JOIN tbl_users as u on a.cuID = u.uID
ORDER BY l.orderBy

the query runs fine, but the ORDER BY is having no affect on the order of the records, can anyone shed any light on why this is happening?




View Complete Forum Thread with Replies

Related Forum Messages:
Queue Size Affect MySQL On RedHat
i want to know if the system parameter somaxconn affect the capabalities
of MySQL to maintain more than five thousands of HTTP connections ?

View Replies !
How Listen Queue Size Affect MySQL On RedHat
i want to know if the system parameter somaxconn affect the capabalities
of MySQL to maintain more than five thousands of HTTP connections ?

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 !
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 !
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 !
Help With ORDER BY
I have this query:

PHP

SELECT p.*, u.points, c.Title AS category, c.CategoryID AS cid, CONCAT(u.FirstName,' ',u.LastName) AS user,
u.UserID AS uid, COUNT(b.UserID) AS referrals
FROM products AS p, categories AS c, ltd_user AS u
LEFT JOIN ltd_user b on p.UserID=b.referrer
WHERE p.section=c.CategoryID AND u.UserID=p.UserID AND p.pppicture != '' AND b.ConfirmS = 1 AND b.UniqueIP = 1 and p.power=1
AND u.points>=10 AND p.section IN (1,2,3,4,5,8,9,10,11,12,13)
GROUP BY p.productid
ORDER BY p.bid DESC, referrals DESC LIMIT 0,10

problem is that query order only by p.bid while I need to sort by both


View Replies !
Order By?
The following mysql statement produces a buch of unordered results:
SELECT Approve, ID, Name, Image1 FROM PROVIDER WHERE Approve = Ƈ' LIMIT $from, $max_results;
3
1
5
7
4
6
2
Id like to place an ORDER BY thing in there (ORDER BY ID(asc))
so it appears like this;
1
2
3
4
5
6
7
How do I do that?

View Replies !
Order By A Sum?
Ok this is really hard to explain. Table1 has userid's that correspond to another table along with 2 other fields num1 and num2. I need to get the 15 userids from Table1 with the highest SUM(num1) / SUM(num2). I can do this with PHP but would like to do it solely using SQL.


View Replies !
'Order By'
I'm pulling a list of links out of a DB and ordering by their 'order id'.

instead of getting (for example) '1,4,7,12,22', I'm getting '1,12,22,4,7'.

View Replies !
Order Within Order
I have this query:

Code:
$sql = "SELECT p.id, p.name, c.name FROM projects p, category c WHERE c.id=p.category_id ORDER BY c.name"
that sorts my projects per category. Now within one category, i need to sort the projects per name

View Replies !
Order By And Count
I have been trying to do a similar thing for a number of different
tables but have given up as i could not find a way to do it but it
seems an obvious thing many pople would want to do so i thought i would
ask once more to see if it is possible.

I have a mysql table like this
Id01 Maidstone KENT
Id02 Ashford KENT
Id03 Bristol AVON
Id04 Westminster LONDON
Id05 Bath AVON
Id06 Chatham KENT

Is there a way to order the table by the county and get total for the
number of rows fro meach county (for output to a coldfusion page) e.g.

KENT (3)
Chatham
Maidstone
Ashford
AVON (2)
Bristol
Bath
LONDON (1)
Westminster

Though formating does not matter

View Replies !
Order By With Group By
If I have a GROUP BY statement, which groups my multiple fields, e.g.:

SELECT ......GROUP BY date, store

can I have multiple ORDER BY statements with that? e.g.:

SELECT ......GROUP BY date, store ORDER BY date asc, store, desc

Is this an acceptable syntax?

View Replies !
Order By With Variable
I have listings with coordinates, i would like to do ORDER BY and
display listings with coords first. If they don't have coords the value
is blank and the coords go both positive and negative values. So i
tried an "ORDER by l_xcoord HAVING l_xcoord<>0" but this is acting like
a WHERE statement removing all results with no coords. I tried GROUP BY
as well but same results.So the question is how can i display all results with the ones that have coords first? It seems like it should be simple but I'm just not
seeing it.

View Replies !
Order By Primary Key
I'm building an Ajax table which fetches its contents from mySQL. The
idea is that the table displays x results on each page, and when you
click 'next page' it downloads the next x results and displays them.

The table uses an arbitrary SQL string to fetch results, and I'm stuck
on how to access just a small result set. Since the SQL is arbitrary I
can't use WHERE myfield = somevalue, because I don't know what
'myfield' is.

I'd like to substitue 'myfield' for the primary key of whatever table
I'm accessing.

So "select * from table where myfield < x and myfield y" becomes
"select * from table where table_primary_key < x and table_primary_key

View Replies !
ORDER BY Regex?
I have a list like this:

Reckless Engineer
St Bonaventures
The Blue Mountain
The Croft
The Cube Club
The Folk house

I'd like to reorder that ignoring the leading "The".

View Replies !
SQL Sort (Order By)
I have sql statement below ,


SELECT
serial_no,host_name,chasis_model,chasis_flash_size ,chasis_dram_size,
country,city,building,other,chasis_sw_version,stat us,chasis_eos,chasis_eol,chasis_user_field_1,chasi s_user_field_2,chasis_user_field_3
FROM tbl_chassis ORDER BY country = '', country


However , my user would like to sort by country,city,building and other
columns .
Anybody have ideas how to do that ? I do order by
country,city,building,other gave me the result which i not expected.

For example below data before sort

Country City Building Other
Thailand Bangkok 208 Wireless RD
Thailand Bangkok 208 Wireless RD
Thailand Bangkok 208 Wireless RD
Thailand Bangkok 208 Wireless RD
Thailand Bangkok 83 Aber rd
Thailand Bangkok
Thailand Bangkok 12 Godieon Rd
Thailand Bangkok 900 Telepark

After sort

Country City Building Other
Thailand Bangkok 83 Aber rd
Thailand Bangkok 12 Godieon Rd
Thailand Bangkok 900 Telepark
Thailand Bangkok 208 Wireless RD
Thailand Bangkok 208 Wireless RD
Thailand Bangkok 208 Wireless RD
Thailand Bangkok 208 Wireless RD
Thailand Bangkok

View Replies !
Order By :: Using IN Clause
SELECT * FROM kf_gallery WHERE gallery_id IN ( 3, 1, 2 ) ORDER BY ?

What I'm trying to do is get the results in the order specified in the "IN" clause, i.e. (3, 2, 1). Is this possible? (I'm having trouble searching the mail archives).

View Replies !
Force Order
I'm working on a web page in php with a mysql DB. I'm trying to list
some products with some other information but I'm having trouble tying
them together. Is there a way to force a very specific order to be
returned? What I need to be able to do is have a query like

"select * from products where prodID = 'thing1' or prodID = 'thing2'
or prodID = 'thing3'...
but I need it to come back in that EXACT order, product matching
thing1 first thing2 second and so on.

View Replies !
Using Order By Clause
I am having trouble optimizing the query:
select * from article order by article_id;
for a MyISAM table that looks like this:

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 !
ORDER BY With Accents
When I sort texts with accents the accents end up in the end instead of near
the same text without accent.

For example, the 3 composers Händel, Haydn and Holst will appear in the
order Haydn, Holst, Händel.

Is it possible to instruct MySql to ignore the accents so that Händel comes
in first instead of last?

View Replies !
ORDER BY :: Accents
When I sort texts with accents the accents end up in the end instead of near the same text without accent.

For example, the 3 composers Händel, Haydn and Holst will appear in the order Haydn, Holst, Händel.

Is it possible to instruct MySql to ignore the accents so that Händel comes in first instead of last?

View Replies !
Manipulating ORDER BY
I have a table, say

----------
ID|myvalue
----------
1|B
2|C
3|A
4|A
5|B
6|C
----------

Is it possible to perform a SELECT statement so that the output gets
ordered by column "myvalue" by B, then A, then C ?

Someting like:
SELECT * FROM mytable ORDER BY myvalue('B','A','C');

This is only an example of course but I wonder if this principle were
possible.

View Replies !
Order By Difference
I'm trying to do a MySQL Query using Mysql 3.23.58 something like that below

SELECT name FROM customers WHERE name LIKE "Fred" ORDER BY
difference(name,"Fred");

The difference piece doesn't seem to be working (Syntax Error returned). Is
this not possible without upgrading the server? or am I doing something
wrong, all I want to do is be able to return the results closest to that
entered first.

View Replies !
About ORDER BY With & Without LIMIT
Im currently on an experiment on combining orderby with/without limit.

For example, i have a total of 50 rows

On this query: .....

View Replies !
Case + Order By
___Name

___Age

___Address

___Place

how I will arrange his in sort order according to user enters and which i need to select from a database file.

Like select * from table where conditions order by ?

View Replies !
Order By One Of Two Possible Fields
Sample Data for this example:

id 100

number 300

name HBO

source 0

id 569

number 9000

name HBO HD

source 300

View Replies !
Alphabetical Order A - M And N - Z
I have searched but cannot find an answer to probably a basic question. I would like to have 2 dropdown lists by order of Lastname, the first a-m and second n-z.... How can you do a query like this? I have a basic query below...thanks in advance
PHP Code:

."SELECT distinct(firstname),lastname       
FROM 
  clients order by lastname" 

View Replies !
Begin ORDER BY With
Is it possible to ORDER BY year ASC and then say that you want to start with year 2000 for example and not with 1888?I am a beginner with PHP/MySQL and wonder how I could write this maybe something like:
"SELECT * FROM design ORDER BY year ASC BEGIN WITH year = 2000";

View Replies !
DB Column Order
How do you change change the column order of a database in PHPmyadmin ?

For example, database A is setup like

ID, Name, Email, Password, Blah

whereas database B is

ID, email, password, name, blah

I want to keep the structure of B and the data from A, but when I do the backup and try to import it, obviously, the data will be in the wrong columns so i need to change the order first, but do not know how to do it.

View Replies !
Controling The Order
I am using phpMyAdmin 2.6.4-pl3
I would like to export data from one of my tables
However, I would like to control the order of the records being exported. Is this possible?

View Replies !
[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 Replies !
Order Of Statements
Does the order of the statements in a mysql WHERE clause have an importance of how mysql evaluates the query?

Ex: are those equal?

WHERE id=5 AND title="horse"

and

WHERE title="horse" AND id=5

thx

View Replies !

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