Shaitan00 Posted November 17, 2005 Posted November 17, 2005 I have a Database (Access) that has a Table Called "Database Information" - it stores adminstrative information on the database. Anyways - I only want the table to have one row of information and I want to keep updating that one single row. So, for starters, if the table is empty (which I can test for to see the row count) then I do a simple INSERT statement to create my first row. Now the problem is - going forward I just want to keep updating that one row/record - is there a way to specify in the statement that I am want to UPDATE row0 (the first row?) Other then the typical SELECT * FROM TABLE (which should only return one row, if there is more then one something is really odd) and then getting the ID (nID) name and doing an UPDATE WHERE ID=nID (or something)... etc... sounds really inneficient. So I thought there must be a way to specify ROW0 (the first row) - this would be much better AND if ever a second row was inserted by accident my program would still work correctly. Any hints/thoughts would be appreciated, Thanks, Quote
penfold69 Posted November 17, 2005 Posted November 17, 2005 use the LIMIT clause: UPDATE yourTable SET yourField="yourValue" LIMIT 1 Quote
*Experts* Nerseus Posted November 17, 2005 *Experts* Posted November 17, 2005 If your table has only one row, then just UPDATE without using a WHERE clause at all. That will UPDATE every row in the table, in your case just one. -ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.