Equals(=) vs. LIKE

后端 未结 15 2037
情书的邮戳
情书的邮戳 2020-11-22 15:19

When using SQL, are there any benefits of using = in a WHERE clause instead of LIKE?

Without any special operators, LIKE

15条回答
  •  囚心锁ツ
    2020-11-22 15:32

    For this example we take it for granted that varcharcol doesn't contain '' and have no empty cell against this column

    select * from some_table where varcharCol = ''
    select * from some_table where varcharCol like ''
    

    The first one results in 0 row output while the second one shows the whole list. = is strictly-match case while like acts like a filter. if filter has no criteria, every data is valid.

    like - by the virtue of its purpose works a little slower and is intended for use with varchar and similar data.

提交回复
热议问题