What is the difference between the '=' operator and LIKE when no wildcards are used

I ask this question because I cannot find the question for the same reason. The reason is that when I use LIKE , I get the STATUS OF RESULTS, and when I use the operator (=), I get INCONSISTENT RESULTS.

BUSINESS
I have a LARGE VIEW (viewX) with several inner joins and left joins where some columns have null values ​​as this allows the definition of the database.

  • When I open this VIEW, I see, for example: 8 lines.
  • When I run, for example: select * from viewX where column_int = 34 and type_string = 'xyz' , this query shows me 100 rows that are not defined as a result of the view. [UNSTABLE]

BUT

  • When I run select * from viewX where column_int = 34 and type_string like 'xyz' , this query shows me only 4 rows that are defined in the view when opened (see 1.) [CONSISTENT]

Does anyone know what is going on here?

+4
source share
2 answers

From the documentation .....

'In the SQL standard, LIKE matches each character, so it can produce results other than statement = comparisons:'

more important (when using LIKE):

' string comparisons are not case sensitive unless one of the operands is a binary string

from: http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html

+2
source

In the MySQL documentation, LIKE works differently than = , especially when you have trailing or leading spaces.

You need to post your actual request, but I assume it is related to known deviations.

+2
source

Source: https://habr.com/ru/post/1368949/


All Articles