SQL Server: What does 1 ++ 2 mean?

前端 未结 2 1181
挽巷
挽巷 2020-12-20 12:54

SQL Server\'s T-SQL syntax seems to allow multiple plus signs in succession:

SELECT 1 + 2 --3
SELECT 1 ++ 2 --3
SELECT 1 ++++++ 2 --3
SELECT 1 + \'2\' --3
SE         


        
2条回答
  •  一向
    一向 (楼主)
    2020-12-20 13:24

    SELECT 1 ++ 2 means 1 plus (+2) which means 3

    Same logic for the others 1+(+(+2)) and so on

    SELECT '1' + '2' --'12' you are concatenating 2 strings, string '1' and string '2', which results '12'

提交回复
热议问题