How does access implement cascading deletion?

Source: Internet
Author: User

The database has two consumption-related tables, xfjl (primary consumption record) and xfxxjl (consumption detail record). The two tables have a master-slave relationship, however, I have not established the relationship between tables in the database.CodeDirectly write SQL statements, such as the delete from xfjl where condition. There is no condition for clearing the original data. You can directly delete all the records in the table, and then add a time period to delete only the data in a certain time period, but the xfxxjl table does not have a consumption time, all records are recorded in xfjl. How can I delete the qualified records in the xfxxjl table?

Try the statement: delete from xfxxjl inner join xfjl on xfxxjl. xfxxjl_zd = xfjl. xfjl_zd where xfjl. Limit>: dt1 and xfjl. xfjl_xfsj <dt2; Syntax Error!

Delete xfxxjl from xfxxjl inner join xfjl on xfxxjl. xfxxjl_zd = xfjl. xfjl_zd where xfjl. xfjl_xfsj>: dt1 and xfjl. Limit <dt2; Syntax Error!

After searching for half a day in Google, I found that SQL Server mostly uses triggers. Continue searching and finally find one: Use the integrity of the reference!

You don't have to write anything in the code. You just need to establish the relationship between the two tables. The original post content is as follows:

Take Access 2003 as an example: You can create a relationship between tables in the tool menu relationship. In the edit relationship dialog box, there is an implementation reference integrity. Check it, below is a list of "cascade update related fields" and "cascade Delete related records". Isn't it checked! As shown in the preceding table, you can create the master table idname = slave table idname, and then edit their relationships! OK?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.