Re: [PHP-DB] ORDER BY DESC

2011-06-20 Thread Chris Stinemetz
On Mon, Jun 20, 2011 at 3:49 PM, Karl DeSaulniers wrote: > Try.. > > $posts_sql = "SELECT posts.post_store, posts.post_content, posts.post_date, > posts.post_by, users.user_id, users.user_name FROM posts LEFT JOIN users ON > osts.post_by = users.user_id WHERE posts.post_store = " > .mysql_real_esc

Re: [PHP-DB] ORDER BY DESC

2011-06-20 Thread Karl DeSaulniers
Try.. $posts_sql = "SELECT posts.post_store, posts.post_content, posts.post_date, posts.post_by, users.user_id, users.user_name FROM posts LEFT JOIN users ON osts.post_by = users.user_id WHERE posts.post_store = " .mysql_real_escape_string($_GET['id'])." ORDER BY posts.post_date DESC";

Re: [PHP-DB] ORDER BY DESC

2011-06-20 Thread Gavin Chalkley
Chris, Try this: http://dev.mysql.com/doc/refman/5.0/en/order-by-optimization.html On 20 June 2011 20:56, Chris Stinemetz wrote: > I have the bellow sql query. What is the correct way to add ORDER BY > posts.post_date DESC > > I would like to add it to the end of my query, but I am just gettin

Re: [PHP-DB] ORDER BY relevance DESC query

2011-04-12 Thread Adriano Rodrigo Guerreiro Laranjeira
Hey friend. The problem is here: ( SELECT `reference`, `organization` FROM `ministry_profiles`... In a subselect, you must select just one column. You are selecting two "reference" and "organization". If you really need both, so you must do two subselects: one for "reference" and another for

Re: [PHP-DB] Order By [blank]

2006-12-21 Thread Kevin Murphy
I haven't tried the union method the query i have is actually quite a bit more complicated than just a simple select * from a single table, so while it may work, it might take a while to write it if I am reading all this right. But yes, the ifnull() method works just fine. Thanks for yo

Re: [PHP-DB] Order By [blank]

2006-12-21 Thread tg-php
You shouldn't have to do that. the IFNULL() handles all that. If the item is null, it returns an emptry string ''. If it's blank/empty, it returns an empty string. This is just used for the comparison = ''. This determines if it's empty or null and if so, returns 'ZZ',

Re: [PHP-DB] Order By [blank]

2006-12-21 Thread David Mitchell
In case the blank is a null or is really a blank: select * from blank where tchar_10 is not null and tchar_10 != '' union all select * from blank where tchar_10 is null or tchar_10 = '' - Dave On 12/21/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: This is a little weird looking, but should

Re: [PHP-DB] Order By [blank]

2006-12-21 Thread tg-php
This is a little weird looking, but should do the job. Remember that items in your 'order by' can be manipulated conditionally. In this case, I'm looking for NULL as well as '' (empty) and changing it to something that should come after all your normal alphabetical values, but it doesn't chang

Re: [PHP-DB] Order By [blank]

2006-12-21 Thread tg-php
This is a little weird looking, but should do the job. Remember that items in your 'order by' can be manipulated conditionally. In this case, I'm looking for NULL as well as '' (empty) and changing it to something that should come after all your normal alphabetical values, but it doesn't chang

Re: [PHP-DB] Order By [blank]

2006-12-21 Thread David Mitchell
What about a union? Does mySql 4.0.x support it? select * from blank where tchar_10 != '' union all select * from blank where tchar_10 = '' - Dave On 12/21/06, Naintara <[EMAIL PROTECTED]> wrote: Depending on your MySQL version you could use a subquery by combining the two queries you men

Re: [PHP-DB] Order By [blank]

2006-12-21 Thread Kevin Murphy
Unfortunately, I'm on 4.0.x so sub-queries are out. And yeah, I should get my host to upgrade but we both work for the government so that isn't happening. ;-) Any other thoughts. -- Kevin Murphy Webmaster: Information and Marketing Services Western Nevada Community College www.wncc.edu 7

RE: [PHP-DB] Order By [blank]

2006-12-21 Thread Naintara
Depending on your MySQL version you could use a subquery by combining the two queries you mentioned, for a fairly straight-forward query. http://dev.mysql.com/tech-resources/articles/4.1/subqueries.html http://mysqld.active-venture.com/Subqueries.html You could read about optimizing subqueries fo

RE: [PHP-DB] ORDER BY

2006-10-18 Thread Miguel Guirao
Yes! Just separate your columns with commas! Check out the proper sintax!! -Original Message- From: Ron Piggott (PHP) [mailto:[EMAIL PROTECTED] Sent: Miércoles, 18 de Octubre de 2006 06:58 p.m. To: PHP DB Subject: [PHP-DB] ORDER BY Is it possible to do an ORDER BY column_a column_b AS

Re: [PHP-DB] ORDER BY

2006-10-18 Thread Chris
Ron Piggott (PHP) wrote: Is it possible to do an ORDER BY column_a column_b ASC ? IE Can you specify two columns to cause the output to be displayed in a specific order? Ron Yes (a quick search would have told you this too). It's best to specify the order for each one: order by column_a a

Re: [PHP-DB] 'Order by' question

2005-02-09 Thread John Holmes
[EMAIL PROTECTED] wrote: Hi, I have a MySQL varchar column which I wish to display. Most of the entries are numbers eg 1, 2, 3 etc etc. But some are numbers and letters eg 34A, 34B, 35A. When I display the column I am able to sort by number using the "order by column_name+0" command, as in: $result

Re: [PHP-DB] ORDER BY Query

2003-09-05 Thread John W. Holmes
Shaun wrote: I have a table in my database called Users. This table has (among others) two columns called Location and Name. Location will be either 1, 2, 3, or 4. How can I produce a query that groups the result into Location and then for each Location order the User by Name? Learn SQL, please.

Re: [PHP-DB] order by an average in another table (basically a "top 10" list)

2003-06-18 Thread Metin Kale
Just a shot in the dark.. it may be wrong, but try it out.. "SELECT avg(rating) AS avgrating FROM ratings WHERE parent_id = '$id' ORDER BY avgrating DESC LIMIT 10" try that out.. should work. metin At 04:06 PM 6/18/2003 -0400, chris wrote: I've done a google search, but most of the results are

Re: [PHP-DB] order by problem

2002-03-21 Thread guslist
Thank you all for the Tip ! It work´s fine now !! :) Gus - Original Message - From: <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Wednesday, March 20, 2002 10:32 AM Subject: Re: [PHP-DB] order by problem > On Wed, 20 Mar 2002 [E

Re: [PHP-DB] order by problem

2002-03-20 Thread [EMAIL PROTECTED]
On Wed, 20 Mar 2002 [EMAIL PROTECTED] wrote: You have your ctrlnumber field defined as varchar. If you define ctrlnumber as number, you could also use SELECT max(ctrlnumber) FROM table WHERE id=14; Cheers Urosh > Hello All, > > I´m having a 'problem' that I dont know how to resolve. The proble

Re: [PHP-DB] order by problem

2002-03-20 Thread cal
Make CtrlNumber a numeric value instead of a string. =C= * * Cal Evans * Techno-Mage * http://www.calevans.com * - Original Message - From: <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, March 20, 2002 7:21 AM Subject: [PHP-DB] order by problem > Hello All, > > I´m having

Re: RE: [PHP-DB] Order By for search results ???

2001-10-19 Thread Russ Michell
>Maybe I'm slow...I'm trying to decipher what you're trying to do. Show us your table >layout >Show us your search criteria and code >Show us a dump of your table so we can see what the data look like ahhh give the chap a break, this is 4th (or so) posting. he thinks we're all wonderful! Let's

RE: [PHP-DB] Order By for search results ???

2001-10-18 Thread Rick Emery
Maybe I'm slow... I'm trying to decipher what you're trying to do. Show us your table layout Show us your search criteria and code Show us a dump of your table so we can see what the data look like -Original Message- From: Chris Payne [mailto:[EMAIL PROTECTED]] Sent: Thursday, October

Re: [PHP-DB] order by question

2001-09-11 Thread Steve Farmer
Hi Andrius, try "order by date desc" Steve At 9:12 PM -0700 11/9/01, Andrius Jakutis wrote: >Ok, here is the question: > >I write to order by date "Order by date". > >So, it output's something like this: > >2001 08 01 >2001 08 02 >2001 08 03 > >What if I want to order by date, but not from the o

Re: [PHP-DB] order by question

2001-09-11 Thread Jason Wong
- Original Message - From: Andrius Jakutis <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, September 12, 2001 12:12 PM Subject: [PHP-DB] order by question > Ok, here is the question: > > I write to order by date "Order by date". > > So, it output's something like this: > >

RE: [PHP-DB] order by date

2001-08-09 Thread Michael Rudel
Hi Scott, RTFM. Anyway: '... ORDER BY Date DESC' will do the job for you. Greetinx, Mike Michael Rudel - Web-Development, Systemadministration - Besuchen Sie uns am 20. und 21. August 2001 auf der online-marketing-düsseldorf in Halle 1 Stand E 16 _

RE: [PHP-DB] order by date

2001-08-09 Thread Dave Watkinson
you can use order by date DESC for descending or order by date for ascending nice to see a PHP-Database question in here ;-) Dave -Original Message- From: Scott Chapman [mailto:[EMAIL PROTECTED]] Sent: 09 August 2001 10:50 To: [EMAIL PROTECTED] Subject: [PHP-DB] order by date Hi

Re: [PHP-DB] Order by unix timestamp

2001-07-12 Thread leo g. divinagracia iii
try the RSORT (reserve sort) function??? Andreas Iwanowski wrote: > > Hello, > i have a table where unix timestamps are inserted when adding a record. > > If i read out the table data, i want to order it by unixtime ( the name of > the filed where the timestamp is ) > > He orders it by unixti

Re: [PHP-DB] Order by unix timestamp

2001-07-12 Thread Andreas Iwanowski
Thank you "Steve Brett" <[EMAIL PROTECTED]> schrieb im Newsbeitrag [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > > -Original Message- > > From: Andreas Iwanowski [mailto:[EMAIL PROTECTED]] > > Sent: 12 July 2001 16:09 > > To: [EMAIL PROTECTED] > > Subject: [PHP-DB] Order by unix times

Re: [PHP-DB] Order by unix timestamp

2001-07-12 Thread Andreas Iwanowski
Vielen Dank "Michael Rudel" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 02bb01c10ae5$38128190$[EMAIL PROTECTED]">news:02bb01c10ae5$38128190$[EMAIL PROTECTED]... > ORDER BY unixtime DESC > > (it default orders by asc, not desc) > > Greetinx, > Mike > > Michael Rudel > - Web-Development, Systemadmi

RE: [PHP-DB] Order by unix timestamp

2001-07-12 Thread Steve Brett
> -Original Message- > From: Andreas Iwanowski [mailto:[EMAIL PROTECTED]] > Sent: 12 July 2001 16:09 > To: [EMAIL PROTECTED] > Subject: [PHP-DB] Order by unix timestamp > > > How can i fix the problem that the records are ordered by unixtime, > beginning with the newest record ? orde

RE: [PHP-DB] Order by unix timestamp

2001-07-12 Thread Michael Rudel
ORDER BY unixtime DESC (it default orders by asc, not desc) Greetinx, Mike Michael Rudel - Web-Development, Systemadministration - Besuchen Sie uns am 20. und 21. August 2001 auf der online-marketing-düsseldorf in Halle 1 Stand E 16 ___

Re: [PHP-DB] ORDER BY in MYSQL ? 8(

2001-05-18 Thread Bob Hall
>question: > >Do any of you knwo how to correctly sort output from a query that contains >"Umlaut" like " Ä Ö Ü" etc. so that it looks like this: > >A >Ä >B >C >D > >O >Ö >P >R > > >and not like MYSQL does it now with the ORDER BY function, which puts all >the "Umlaut" at the end like this