How to query multiple tables in the tp framework

Source: Internet
Author: User
Tags openid
For example, two tables, apply and activityapply, have the openid field and the idac_id of activity. Now we need to query openid and all records with openid in the apply table. How can we write an SQL statement, for example, two tables? the openid and activity id ac_id fields in the apply and activity apply tables now need to be queried in the apply table and all records with openid in the activity table. How can I write an SQL statement?

Reply content:

For example, the openid and activity id ac_id fields in the apply and activity apply tables of two tables need to be queried in the apply table and all records with openid in the activity table. How can I write an SQL statement?

M ('application')-> field ('a. openid, ac. * ')-> alias ('A')-> join (' _ ACTIVITY _ ac ON. ac_id = ac. id')-> select ();

That's what it means.

If you want an SQL statement, it has nothing to do with the framework. For example, a box is added with the same SQL statement,
If you are asking how to define the model change in tp, see the view model section in the official documentation for details.

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.