我们是否必须使用PHP [duplicate]在SQL where子句中连接变量

I have this code:

$sql=mysqli_query($dbc, "SELECT * FROM users WHERE user = '".$username."'");

but why so many people do this if

$query = "SELECT type FROM users WHERE user = '$username' ";

works fine too? And if we have multiple values we can just do

$query = "SELECT type FROM users WHERE user = '$username', '$pass' ";

I couldn't find any explanations on this syntax on the internet.

</div>