A mysql query problem in PHP?

Source: Internet
Author: User
The problem is as follows: {code...} The problem is as follows:

Create an APP interface to obtain the contact list, but the contact score is 0. administrator 1. bind user 2. friends and family 3. app friend, and then there is an im table with a corresponding im_id. When the contact is 0 and 1, im_id is returned. If it is 2 or 3, No. if we only return a result and there is no type condition, join is enough, but now there is a type difference. how can this be done?

Reply content:

The problem is as follows:

Create an APP interface to obtain the contact list, but the contact score is 0. administrator 1. bind user 2. friends and family 3. app friend, and then there is an im table with a corresponding im_id. When the contact is 0 and 1, im_id is returned. If it is 2 or 3, No. if we only return a result and there is no type condition, join is enough, but now there is a type difference. how can this be done?

Assume that the list of contacts obtained is a user table. You mean there is a contact type in this user table, right?
Since you say that you want to use join, there may be two tables, so there must be a connection between the two tables.
SELECT im. im_id WHERE user left join im ON user. im_id = im. im_id WHERE user. im_id IN (0, 1 );

Actually, I don't know how to understand it?
If it is sharded, adding a where limit is not enough. 0 0.
For exampleWHERE im. im_id IN (0, 1)

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.