|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
Member (7 bit)
|
SQL - complicated query
Hi,
suppose i have a table with a single column. And i wanna do query that does the following: if table is empty insert value x into the table else // here in this case the table will have one row ONLY update the only existing row to value x end is it possible to do something like "insert or update" query? |
|
|
|
|
|
#2 |
|
Come in Ray...
Join Date: Sep 2004
Posts: 1,668
|
Here is some psuedocode you could use in your program:
Code:
recordset = "SELECT Count(*) AS NumRecords FROM TableName"
if recordset(NumRecords) > 0 then
//record already exists, delete it
RunSQL("DELETE FROM TableName")
end if
//the table is empty, insert the new
RunSQL("INSERT INTO TableName VALUES(" + Value + ")"
|
|
|
|
|
|
#3 |
|
Member (7 bit)
|
tnx
![]() i will do: count rows if rows > 0 update else insert end tnx alot |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|