![]() | | ||||||||
| | #1 |
| Advanced Warrior Join Date: Nov 2008
Posts: 609
Thanks: 31
Thanked 1 Time in 1 Post
|
Alright guys I dont know if you can help but I thought I ask ![]() I am trying to set up a mysql query so that I can only display the latest category that has been added to my site... On the table that I am trying to create it under it has got the following infomration.. id (numeric number) cat_name (name of category The id increses by one each time I add new category to the site... For example if I add one now called it Master it will have the id 1 allocated to it.. Then tomorrow I add another category call it Private will have the id 2 to it, and so.. At the moment I can get all categories to be displayed.. I just want it to the latest one.. Can anyone help please?? |
| | |
| | #2 |
| HyperActive Warrior War Room Member Join Date: Dec 2009 Location: Costa Rica
Posts: 172
Thanks: 74
Thanked 44 Times in 42 Posts
|
good morning ![]() Code: select id,cat_name from table_name order by id DESC limit 1 |
| | |
| | |
| | #3 |
| HyperActive Warrior War Room Member Join Date: Dec 2009 Location: Costa Rica
Posts: 172
Thanks: 74
Thanked 44 Times in 42 Posts
|
or.. ![]() Code: select max(id),cat_name from table_name |
| | |
| | |
| | #4 |
| PHP Programmer Join Date: Nov 2009 Location: /dev/null
Posts: 136
Thanks: 5
Thanked 12 Times in 12 Posts
|
Of course, make it super simple to read :] --m4rx |
| We are what we repeatedly do. Excellence, then, is not an act, but a HABIT. ~Aristotle Bored. Check out my blog. | |
| | |
![]() |
|
| Tags |
| mysql, query |
| Thread Tools | |
| |
![]() |