![]() |
||
|
AFKA Hawk/JMU1337
Join Date: Jan 2002
Posts: 6,414
Level: 56
HP: 557 / 1379 |
SQL help?
Just something for my website... Don't care if I never get it to work... been using it as-is for 4 years
![]() I have a database of entries that I want to order by date. I've been ordering them by date simply by putting them into the database in order and sort on their uin. I have a date field, but it's stored as a varchar in mm/dd/yy format. I would like to sort records on that instead so if I forget to put an entry in, I don't have to backtrack to have it get placed in the right place. My current query: $sqldata = "SELECT * FROM ".$db_prefix."entry ORDER BY `uin` DESC"; I've done 5 minutes of messing around with date and type conversion crap, but to no avail. It's not worth me putting in any more time than that, but if any of y'all are SQL gurus, I'm sure you'll have an answer in seconds. The output: http://www.iammike.org/index.php?loc=log |
|||
|
|
|
Hey!
Join Date: Jul 2002
Location: o
Posts: 12,784
Level: 70
HP: 1489 / 1731 |
Haven't done a whole lot of SQL, but enough to know that this is bad times. Why not convert your field into the date type? It's the Right Thing to do...
__________________
Jak: 12 years gone by as if it was yesterday. Not long ago i came to the US barely able to put together a short sentence. Now i can put together one full sentence. |
|||
|
|
|
Soon I'll b racin forealz
Join Date: May 2005
Location: NoVA
Posts: 7,029
Level: 57
HP: 1033 / 1423 |
Have you tried using order by in conjunction with convert?
__________________
Before you talk shit about someone, you should walk a mile in his shoes. That way, when you talk shit about him, you're a mile away and you have his shoes. |
|||
|
|
|
I have a big chin
Join Date: Oct 2004
Location: dc-ish
Posts: 5,910
Level: 54
HP: 732 / 1341 |
google "mysql str_to_date"
if you can't set it to default "10" to "2010" for the year.. then adjust the string date to 2010 and then run str_to_date.. you could even do that on the fly in a subquery.
__________________
Quote:
|
||||
|
|
|
AFKA Hawk/JMU1337
Join Date: Jan 2002
Posts: 6,414
Level: 56
HP: 557 / 1379 |
yes.
AutoMerged DoublePost Quote:
AutoMerged DoublePost will look into this. Last edited by MikeJComputer : 07-30-2010 at 09:32 PM. Reason: Automerged Doublepost |
||||
|
|
|
Soon I'll b racin forealz
Join Date: May 2005
Location: NoVA
Posts: 7,029
Level: 57
HP: 1033 / 1423 |
Yes, obviously that's the right thing to do. He's trying to get us to find a shortcut for him, though.
__________________
Before you talk shit about someone, you should walk a mile in his shoes. That way, when you talk shit about him, you're a mile away and you have his shoes. |
|||
|
|
|
I have a big chin
Join Date: Oct 2004
Location: dc-ish
Posts: 5,910
Level: 54
HP: 732 / 1341 |
Quote:
(because I'm in another country)
__________________
Quote:
|
|||||
|
|
|
AFKA Hawk/JMU1337
Join Date: Jan 2002
Posts: 6,414
Level: 56
HP: 557 / 1379 |
Quote:
![]() |
||||
|
|
|
Hey!
Join Date: Jul 2002
Location: o
Posts: 12,784
Level: 70
HP: 1489 / 1731 |
Quote:
![]()
__________________
Jak: 12 years gone by as if it was yesterday. Not long ago i came to the US barely able to put together a short sentence. Now i can put together one full sentence. |
||||
|
|
|
Pak Chooie Unf
Join Date: Nov 2003
Location: .
Posts: 9,319
Level: 63
HP: 1175 / 1563 |
Pft. What country? Canadia?
__________________
I shove around the blind people. |
|||
|
|
|
AFKA Hawk/JMU1337
Join Date: Jan 2002
Posts: 6,414
Level: 56
HP: 557 / 1379 |
Quote:
|
||||
|
|
|
Soon I'll b racin forealz
Join Date: May 2005
Location: NoVA
Posts: 7,029
Level: 57
HP: 1033 / 1423 |
You all are forgetting how important Mike is and how much each minute of his time is actually worth. If you only knew...
__________________
Before you talk shit about someone, you should walk a mile in his shoes. That way, when you talk shit about him, you're a mile away and you have his shoes. |
|||
|
|
|
AFKA Hawk/JMU1337
Join Date: Jan 2002
Posts: 6,414
Level: 56
HP: 557 / 1379 |
GOD DAMN! Good one!
|
|||
|
|
|
Hey!
Join Date: Jul 2002
Location: o
Posts: 12,784
Level: 70
HP: 1489 / 1731 |
Quote:
![]()
__________________
Jak: 12 years gone by as if it was yesterday. Not long ago i came to the US barely able to put together a short sentence. Now i can put together one full sentence. |
||||
|
|
|
banned
Join Date: Feb 2002
Location: Greenville, SC
Posts: 11,161
Level: 67
HP: 1180 / 1657 |
fucking lol.
|
|||
|
|