Adobe Dreamweaver Forums



Last 10 THreads :         Format numbers with leading zeros (Last Post : charlie656 - Replies : 0 - Views : 1 )           »          Event listener (Last Post : lammspillning - Replies : 2 - Views : 3 )           »          action script for button (Last Post : NedWebs - Replies : 5 - Views : 10 )           »          403 error from my domain? (Last Post : Ken Ford - *ACE* - Replies : 1 - Views : 4 )           »          Adding database RDS Login Dreamweaver 8 Coldfusion 8 (Last Post : ClubbyJMC2008 - Replies : 4 - Views : 5 )           »          Looping from end of clip to middle of clip (Last Post : Gibbah - Replies : 1 - Views : 5 )           »          Help need div to expand to height of browser (Last Post : Tim G - Replies : 1 - Views : 2 )           »          how do I add a table to a preformed template that I got? (Last Post : mb007inc - Replies : 0 - Views : 1 )           »          Downloading from Flash (Last Post : NedWebs - Replies : 1 - Views : 2 )           »          Checking which button is clicked (Last Post : NedWebs - Replies : 3 - Views : 4 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Cold Fusion
 
Tags:



Reply
  #1 (permalink)  
Old 10-06-2008, 04:14 PM
PopcornCoder
 
Posts: n/a
Diggs:
Default How to get last record in query

What's the proper SQL syntax to get the last record in a table.


Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-06-2008, 04:14 PM
Kronin555
 
Posts: n/a
Diggs:
Default Re: How to get last record in query

Depends on the contents of the table.
Reply With Quote
  #3 (permalink)  
Old 10-06-2008, 04:14 PM
Kronin555
 
Posts: n/a
Diggs:
Default Re: How to get last record in query

Depends on the contents of the table.
Reply With Quote


  #4 (permalink)  
Old 10-06-2008, 04:24 PM
PopcornCoder
 
Posts: n/a
Diggs:
Default Re: How to get last record in query

I am going to sort it based on bulletin_id which is an auto numbering column and I want to get another column called bulletin_number.
Reply With Quote
  #5 (permalink)  
Old 10-06-2008, 04:31 PM
Kronin555
 
Posts: n/a
Diggs:
Default Re: How to get last record in query

If bulletin_id is an autonumber column, then you can sort it by bulletin_id
desc and limit 1. That will give you the row with the highest bulletin_id.

select * from foo_table
order by bulletin_id desc limit 1

Reply With Quote
  #6 (permalink)  
Old 10-06-2008, 04:43 PM
Ken Ford - *ACE*
 
Posts: n/a
Diggs:
Default Re: How to get last record in query

SELECT MAX(primary_key_field) AS MaxID
FROM some_table

--
Ken Ford
Adobe Community Expert Dreamweaver/ColdFusion
Adobe Certified Expert - Dreamweaver CS3
Adobe Certified Expert - ColdFusion 8
Fordwebs, LLC
http://www.fordwebs.com


"PopcornCoder" <webforumsuser@macromedia.com> wrote in message
news:gcd9rq$8t3$1@forums.macromedia.com...
> What's the proper SQL syntax to get the last record in a table.


Reply With Quote


  #7 (permalink)  
Old 10-06-2008, 05:13 PM
Dan Bracuk
 
Posts: n/a
Diggs:
Default Re: How to get last record in query

select somefields
from sometables
where somefile = (select max(somefield)
from sometable)
etc
Reply With Quote
  #8 (permalink)  
Old 10-07-2008, 09:54 PM
trubel
 
Posts: n/a
Diggs:
Default Re: How to get last record in query

The best way if you are using MS SQL is;

Select MAX(bulletin_id) as LastRecord
From (your tablename)
Reply With Quote
  #9 (permalink)  
Old 10-07-2008, 09:54 PM
paross1
 
Posts: n/a
Diggs:
Default Re: How to get last record in query

[Q]Select MAX(bulletin_id) as LastRecord....[/Q]This would return the last bulletin_id, not the last entire record.... Dan's suggestion is more likely to give the correct results.

Phil
Reply With Quote


Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 01:28 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk