0

what is the differences between = to like ?

thanks for help :) by the way if it's help , the error i get is: the data types text and varchar are incompatible in the equal to operator [msg 402]

1: enter image description here

Blorgbeard
  • 101,031
  • 48
  • 228
  • 272
Antonio
  • 17
  • 8
  • It depends on the context you are referring to. If you make use of `Like` the SQL engine would search for the occurrence of that string irrespective of the position in a row or of it is preceded or followed by other words in the row. Whereas , if you make use of `Where column ='string'` the engine make sure that it is only that string that is present in a row with no word before or after it – james jelo4kul Oct 16 '15 at 00:51
  • @jamesjelo4kul Thanks for replaying. I didn't understand you so much. but never mine. I found an answer but i must explain on something , look at this code: `code` SELECT ID, MyText FROM TestTable WHERE CONVERT(NVARCHAR(MAX), MyText) = N'AnyText' GO `code` i have to convert name var in my code to varchar ? why is that? – Antonio Oct 16 '15 at 00:57

1 Answers1

0

Like

The LIKE operator is used to search for a specified pattern in a column.

Where

The WHERE clause is used to extract only those records that fulfill a specified criterion.

In your case the first query do not work is because no records match the criteria you are searching.

cw fei
  • 1,534
  • 1
  • 15
  • 33