Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Question

Status
Not open for further replies.

jchollo

MIS
Sep 15, 2005
22
US
I have a table with a field called Status of Action which has the choices to choose Active, Completed, Closed.

Once an item is closed, how do I go about placing this entry in a closed table. Do I have to set up another table named Closed. How would I write the code to put an entry once closed in another table.

tks
 


Hi,

What would the PURPOSE be for putting closed rows in a separate table? Are we talking about millions of rows?

Skip,

[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue]
 
Doing so will violate the relational database rules. You can't pull it out of that table. Use a query.
 
The usual mechanism is
Code:
INSERT INTO myClosedTable
Select * From myOtherTable Where Status = 'CLOSED'

followed by

Code:
DELETE * From myOtherTable Where Status = 'CLOSED'

As the others have said though, unless performance is a big issue for the table, you are making an attribute of the data (i.e. CLOSED or NOT CLOSED) dependent on data location. Given that it is a data attribute, it should be a field in the table and all data should be in the same table.
 
ok - I see. I guess I was thinking when an item is closed, I wanted it not to appear in the table. But creating a query for the active items would do the trick.

tks for enlighten me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top