i want to get the last value of the database and the database look like this
table name prospec
TranID data item
1 02/02/2004 2
2 02/02/2004 2
3 02/02/2004 3
4 02/02/2004 3
i want to get the value (4) which auto generate by itself
i try "select TranID from prospec order by TranID desc limit 1"
then when i run it then this error came out "incorrect syntax new 'limit' "Originally posted by mrbear
i want to get the last value of the database and the database look like this
table name prospec
TranID data item
1 02/02/2004 2
2 02/02/2004 2
3 02/02/2004 3
4 02/02/2004 3
i want to get the value (4) which auto generate by itself
i try "select TranID from prospec order by TranID desc limit 1"
then when i run it then this error came out "incorrect syntax new 'limit' "
What type of database are you using?|||Originally posted by ika
What type of database are you using?
i'm using sqlserver databse|||Originally posted by mrbear
i want to get the last value of the database and the database look like this
table name prospec
TranID data item
1 02/02/2004 2
2 02/02/2004 2
3 02/02/2004 3
4 02/02/2004 3
i want to get the value (4) which auto generate by itself
i try "select TranID from prospec order by TranID desc limit 1"
then when i run it then this error came out "incorrect syntax new 'limit' " For MS-SQL 7.0 or later, you probably want:SELECT TOP 1 TranID
FROM prospec
ORDER BY TranID DESCYou can actually get the same result much more portably by using:SELECT Max(TranID)
FROM prospecThis should work on any database that supports SQL-89 or later.
-PatP|||Originally posted by Pat Phelan
For MS-SQL 7.0 or later, you probably want:SELECT TOP 1 TranID
FROM prospec
ORDER BY TranID DESCYou can actually get the same result much more portably by using:SELECT Max(TranID)
FROM prospecThis should work on any database that supports SQL-89 or later.
-PatP
In SQL 7 or later, you also want:
SELECT
MAX(TranID)
FROM
prospec|||thanks guys, the statment works. Thanks a million times|||Originally posted by derrickleggett
In SQL 7 or later, you also want:
SELECT
MAX(TranID)
FROM
prospec also?
isn't that what Pat said? you even quoted him!!!!!!
and what's up with the "SQL 7 or later" qualification??
are you saying select max(foo) from bar won't work in 6.5??
whoasql
Showing posts with label thistable. Show all posts
Showing posts with label thistable. Show all posts
Friday, March 23, 2012
Subscribe to:
Posts (Atom)