|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I know this solution has to be easy but I can not find many references to it on the Internet or through any MSSQL or PHP help.
I am coding a form through PHP using an MSSQL db. I linked the form to a submit.php where the data is written into the database and that works fine; however, after the data is written I would like to use an SQL Query to output the entire last row of data (that was just written in). I know I could use the text box names, but I have a few hidden fields that don't get their data from any text area on the previous page. I do have a unqiue autoincrement number so I'm guessing I could do some type of a query and only display the highest number but I have no idea how to go about it. Any help would be great! Thanks. |
|
#2
|
|||
|
|||
|
If your table does not have a primary key, you should really re-thinkg your DB model.
|
|
#3
|
|||
|
|||
|
Quote:
The primary key is my unique generated number. I apologize I did not specify this, I wasn't sure it would make a difference in the question. Thanks for the reply! |
|
#4
|
||||
|
||||
|
Add a timestamp column to the table, and just select back the row with the biggest timestamp.
__________________
Primary Forums: .Net Development, MS-SQL, C Programming VB.Net: It's not your father's Visual Basic. [Moving to ASP.Net] | [.Net Dos and Don't for VB6 Programmers] |
|
#5
|
|||
|
|||
|
Quote:
I should have stated this earlier, I am a sql noob. I know very little and what I do know, I'm learning out of books. I do, of course, know how to add a timestamp column, but then how would I go back to the biggest one and then output that onto my PHP page? Thanks for the help again guys, I appreciate it. |
|
#6
|
||||
|
||||
|
SELECT TOP 1 * FROM [MyTable] ORDER BY [MyTimestampColumn] DESC
|
|
#7
|
||||
|
||||
|
Quote:
obviously you've never worked in a multi-threaded environment... ![]() fleppar, look up the SCOPE_IDENTITY function in your manual |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Returning Last Entire Row of MSSQL DB |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|