What does the “@” symbol do in SQL?

前端 未结 7 2031
终归单人心
终归单人心 2020-11-28 04:16

I was browsing through the questions and noticed this:

SELECT prodid, issue
FROM Sales 
WHERE custid = @custid 
AND datesold = SELECT MAX(datesold) 
                 


        
7条回答
  •  难免孤独
    2020-11-28 05:07

    The @CustID means it's a parameter that you will supply a value for later in your code. This is the best way of protecting against SQL injection. Create your query using parameters, rather than concatenating strings and variables. The database engine puts the parameter value into where the placeholder is, and there is zero chance for SQL injection.

提交回复
热议问题