Five-table joint check SQL and check box additions and deletions

Source: Internet
Author: User
Tags string format

This is a five-table joint check, if this is not obvious, then add the speech

This makes it obvious that the

This delivery time and place, are a one-to-many, then this menu is many to many, in fact, for the veteran, there is no big deal, but for the novice, I hope it can be a little help, this is written with MyBatis

First of all, we give the SQL to contribute, perhaps some ugly, but this is also to write their own essays do not matter

Select A.*,b.fname from
(Select A.*,c.aname from (select A.*,b.name tname from
T_order A,t_time b where a.time_id=b.id) a,t_address c where a.address_id =
C.aid
Limit #{index},#{limit}
) A
Left Join
(select Order_id,group_concat (f.name) fname from T_order_foot a LEFT join
T_foot F
On a.foot_id = F.id GROUP by order_id) b on a.id = b.order_id ORDER BY
a.ID ASC

That's it, too.

This is the five tables are linked, the rest of how to show how to show on it, for the time being do not watch

So the following is the Add method, the added drop-down is not a table

Write it out in the service

This is the method in the controller.

Delete to delete two times, is to delete the main table, and then delete the multi-table (multi-table is a many-to-many relationship table)

When invoking the FA, the ID of the main table is passed directly to the

So when you modify the echo, because he is multi-table, the ID of a primary table may have multiple foot table IDs so, to traverse

In front of the reception also need to cycle

This can be echoed, of course, do not forget to write in the entity class to traverse the IDs, I give the definition of the string format

Then the formal modification of the method is much simpler, the main table for normal modification can be, but, many tables you have to delete and then add, you have to modify the main table of the illusion, the main table here is the main role of the check box,

I am a novice, I This essay is also for myself to see, of course, can help and I like the small white, it is also my honor, hope that the great God saw not it, thank you!

Five-table joint check SQL and check box additions and deletions

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.