0

I'm developing an application in which users can send private message to each other.
Assume that a user want to send a message to users David , jack, John. Something that is clear I must validate this recipients and check if they exist in the users table.
but I don't have a clear scenario to do this job.

Should I prepare a query like:

select user form users where user_name=David OR user_name=Jack OR user_name=John

Then if row count was 3 let the user send his message and if not drop the action?

4

1 回答 1

1

就 SQL 问题而言,这是非常基本的,因此您确实需要为此类事情获得更好的参考。

您要查找的查询类型是:

SELECT id, user_name FROM users WHERE user_name IN ('David','Jack','John')

大概你有id某种类型的专栏。

如果您要对其进行查询,请记住INDEX在该字段上放置一个。user_name

于 2013-10-16T16:55:56.353 回答