Hello, Is it possible to order a mysql query by the following date notation 06-10-2003 14:40:55 Thanks in advance. G
Hello, Is it possible to order a mysql query by the following date notation 06-10-2003 14:40:55 Thanks in advance. G
Hello, Is it possible to order a mysql query by the following date notation forgot to tell it is like day - month - year 25-12-2003 14:40:55 thanks G
"Spam sucks" <nomail> schrieb im Newsbeitrag Why not make a normal datetime field (format 0000-00-00 00:00:00, year-month-day) which is easy to be sorted (ORDER BY date)? You can change the output to your preferred format easily with PHP, either with the date() function or by exploding and rearranging it. HTH Markus
assuming the above formatted string is in a field called fred, you could add this to the end of your select: order by concat(substring(fred,7,4),substring(fred,4,2),substring(fred,1,2),substring(fred,12)) -- Tom Thackrey www.creative-light.com tom (at) creative (dash) light (dot) com do NOT send email to XXXX@XXXXX.COM (it's reserved for spammers)
1.Distinct Name with date Order by date
On Wed, 28 Nov 2007 20:40:01 +0100, < XXXX@XXXXX.COM > wrote: > Here's my issue. I'm tracking product interest so to speak. Each > time a user clicks on a product the userid, product id, and date is > tracked. Now users usually look at their products of interest several > times. So everytime they click the same product it is tracked as > well. > > So as an administrator I want to look at the product to see who's > checked it out and how many times (ie interest level). > > Here's what I have now > A.A. - Last Access: 11-12-2007 Total: 2 > B.B. - Last Access: 11-26-2007 Total: 2 > > I can onlly get distinct user and order by name. Then while looping > get the last access date. > > But I want the most recent person whos looked at the product to be on > top and don't want see A.A... multiple times. Sure, prefectly possible in just one query. comp.databases.<flavour of your database> or possibly: alt.php.sql (allthough the latter is not in my list, so I won't see it) -- Rik Wasmus
2.SELECT date ORDER BY question
Hi there, I would like to sort a query by date in ascending order, however I do not want 'empty' dates to appear at the top, I want them to appear at the bottom instead. Is there any way I can do this with one SQL query? desired result: 2007-07-11 09:00:00 2007-07-12 10:00:00 2007-07-13 11:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 etc Many thanks, Steve
3.how to order, then limit, then order?
Hello. I hope this question isn't too silly. I am working on a PHP/ mysql application that has a list of (scientific research) papers, a list of keywords, and a list that makes links between the two. What I'm trying to do is to show just the most popular keywords, and to show them in alphabetical order. My approach (illustrated at the end, with a query that workd) is to order by a count of use, and then to limit the results. But, as I imagine the clever folks who read this group will see quickly, the query leaves the keywords ordered by popularity. Q: is there a way that I can get Mysql to take the results of this query and then order them alphabetically, or should I be doing that in PHP? (I assume it would be faster to do it in mysql. And, I may as well admit it, I am enjoying learning mysql, so I'd like to get this task done in that domain instead of in PHP.) Many thanks, to anyone who is kind enough to offer some advice. Dan. THE QUERY IN QUESTION -- SELECT Keyword, KeywordID, count( PaperID ) FROM Papers_Keywords LEFT JOIN Keywords ON ( Keywords.id = Papers_Keywords.KeywordID ) GROUP BY KeywordID ORDER BY count( Keyword ) DESC LIMIT 0 , 5;
4.ORDER BY with special order scheme?
5.Select Records In Order Based on an Ordered ID List
Hello! Let's say I have an ordered list of ids that correspond to an ordered list of records I want to retrieve, ie. 32,80,10,90,28,5 What's the most efficient way to retrieve the records corresponding to the ids in the same order as the ids? It seems the IN clause doesn't preserve ordering, and using UNION to submit the same query with different id WHERE clauses seems messy/inefficient. Thanks! Mike
6. cyrillic in utf8 collation but ORDER BY returns random order
Users browsing this forum: No registered users and 47 guest