473,405 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

how to get the last row inserted into a table.

hi guys,

i know 1 method for this:

select * from table_name where rowid=(select max(rowid from table_name );

cost of this query is 4.

do any body knows any other query with minimal cost

thanks
Dec 14 '07 #1
3 3239
amitpatel66
2,367 Expert 2GB
Hi Parmsingla,

Welcome to TSDN

Please make sure you follow POSTING GUIDELINES every time you post in this forum

Thanks
MODERATOR
Dec 14 '07 #2
amitpatel66
2,367 Expert 2GB
hi guys,

i know 1 method for this:

select * from table_name where rowid=(select max(rowid from table_name );

cost of this query is 4.

do any body knows any other query with minimal cost

thanks
How many records you have in your table?

Query using ROWID is always the best
Dec 14 '07 #3
debasisdas
8,127 Expert 4TB
Where you want to insert the record ?
Dec 14 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: PT | last post by:
I got a problem. And thats..... First of all, I got these three tables. ------------------- ------------------ ---------------------- tblPerson tblPersonSoftware ...
1
by: Ann | last post by:
Hello everyone, hope someone can help me with this. I have a SQL stored procedure that inserts a record into a table, creates a cursor to fetch the last record that was added to get the unique...
3
by: siatki | last post by:
Hello, Firstly, sorry for my english. I have problem with creating SQL statement. I am beginner and I think that it is very easy to do. Look - I have to get only the last 20 records from table...
2
by: mgarriss | last post by:
Given this table: CREATE TABLE test ( id SERIAL, example TEXT ); An implicit sequence is created as show in this message: NOTICE: CREATE TABLE will create implicit sequence 'test_id_seq'...
6
by: Maurizio Faini | last post by:
I have a little problem. there is a way to get last id inserted into db or i have to make a new query? I explain better my question: in vbscript using sqlserver2000 i can use this code: ...
3
by: Ricardo | last post by:
Hi all, I am trying to come up with a sql query (just one query) that returns all the columns for the last N records that were inserted into a table. I have a column in the table that has the...
20
by: Guru | last post by:
Hi I have a table which contains number of rows. I want to fetch the last 5 records from the table. I know for the first 'n' records we can use FETCH FIRST n ROWS ONLY command. But i want to...
10
by: MaRCeLO PeReiRA | last post by:
Hi guys, I am in troubles with a SERIAL field. I have five tables. A parent table and four child tables. When I do the INSERT in the parent table, I have an ID (generated) by the sequence...
4
by: Normann | last post by:
I am creating a Stored Proc and I need to be able to select the last added row, now this should be made easier by the fact that I have a smalldatetime column in the table that is added every time a...
13
rajiv07
by: rajiv07 | last post by:
Hi to all, I want to know how to select a last inserted record which is the primary key is not an integer. my table ramstr(Primary)----name--service XTC01-------Rajiv---service ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.