开发者

How to get friends without cats from MySQL?

I have a plain text as it is list of friends ID's that is not stored in the database, cause I have it in PHP like a string:

7375,8983429,478243

And I have a table users and a table cats.

Table users has a column ID and NAME and table cats has a column ID, NAME, and USER_开发者_JS百科ID.

I would like to get these friends of mine that don't have cats. How to do so?


SELECT * FROM users LEFT JOIN cats ON cats.USER_ID=users.ID WHERE cats.ID IS NULL

To get only specific friends add this to the end of the SQL

AND users.ID IN (7375,8983429,478243)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜