SELECTλ μΌλ°μ μΌλ‘ λ°°μ΄/λͺ©λ‘μ λ°ννμ§λ§ ν΄λΉ λ¬Έμ ν νλ§ λ°νλλ€κ³ κ°μ νλ€.
0νμ λ°νν μ μλ WHERE λ¬Έμ μ¬μ©νλ κ²½μ° νΉμ μ¬μ©μ 컀μ€ν
κ°μ²΄μμ μ΄λ¬ν μ€λ₯κ° λ°μν μ μλ€.
쿼리 κ²°κ³Όμ λν΄ null κ²μ¬λ₯Ό μλμ²λΌνλ List has no rows for assignment to SObject μλ¬κ° λ°μνλ€.
Player__c player = [SELECT Id from Player__c where Name = :username];
if (player != null) p = player.Id;
μμ μ½λ μ²λΌ μ¬μ©μ μ΄λ¦κ³Ό μΌμΉνλ Player__c λ μ½λκ° μμ κ²½μ° μ μ½λλ μ€ν¨νλ©°, μ€μ λ‘λ nullμ λ°ννμ§ μλλ€.
λ€μκ³Ό κ°μ΄ μννλ κ²μ΄ λ μμ νλ€.
Player__c[] players = [SELECT Id from Player__c where Name = :username];
if (players.size() > 0) p = players[0].Id;