What's the difference between “LIKE” and “=” in SQL?

前端 未结 13 896
悲哀的现实
悲哀的现实 2020-12-05 12:56

Is there any difference between:

SELECT * FROM users WHERE username=\"davyjones\"

and

SELECT * FROM users WHERE username LI         


        
相关标签:
13条回答
  • 2020-12-05 13:48

    In that case, there is no difference that would come up in the results. However, it uses a different method for comparision, and the "LIKE" would be much slower.

    Check out this for examples of LIKE : http://www.techonthenet.com/sql/like.php

    In this case, you still want to use the equals.

    Update: Note that there is a crucial difference when it comes to CHAR type columns in which the results will be different. See this answer for more details. When using VARCHAR (presumably the norm), the above are equivalent and equals is to be preferred.

    0 讨论(0)
提交回复
热议问题