When to write "as" the instance just "=" is SQL

in Sybase I saw the code like:

     select * from sys.SYSCOLUMNS where tname like 'table_name';

      

and the result is exactly the same as

    select * from sys.SYSCOLUMNS where tname = 'table_name';

      

why do they write "as" instance "="

I know we can use like% to validate patterns like:

select * from table_name where column_name like 'temp%';

      

but I see no point in doing this when it doesn't match the pattern.

Can anyone explain why they are doing this?

+3


source to share


1 answer


As @HoneyBadger pointed out, in this case (static string) "like" and "=" are functionally the same.

If the coder rarely uses '=' then this is most likely some kind of personal preference.



If the encoder uses a combination of "like" and "=", or usually uses "=", it could be something as simple as the originally tested wildcard encoder and / or testing for NULL (in ANSINULL = true), decided by some then the reason is to switch to a static string and just glossed over changing "like" to "=". A similar explanation, if they cut-n-pasted a piece of code from a different location, replaced the wildcard string with a static string, and obscured the change from "like" to "=".

+1


source







All Articles