How to write query statements in thinkphp

Source: Internet
Author: User
How is the query statement written in thinkphp?
Similar to the kind of QQ, a user information table, the user has some friends, how can I query the user's friend information displayed on the page. Thank you, GGMM!

------Solution--------------------

------Solution--------------------
At least you should give the relevant table structure.
------Solution--------------------
What does it have to do with frames?

You design the relevant database, the corresponding search data can be

You can post the structure of the user table and the buddy table
------Solution--------------------
Presumably the statement, that, assuming the need for UserAccount,
SQL Code
SELECT f.*, U.useraccount from Usersfriend as F left JOIN [user table name] as U on f.frienduserid=u.useridwhere f.userid=[user ID to find]
------Solution--------------------
TP Union Query No, I use TP also direct query (SQL statement)
------Solution--------------------
Basic sql:
Select usersfriend.*
From Usersfriend, userinformation
where Usersfriend.frienduserid = Userinformation.userid

------Solution--------------------
Pass by, accumulate points
  • Related Article

    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.