title: Why would I use ID in MySQL when I can search with the username?
body: <p>In many tutorials about MySQL they often use an ID which is made automatically when an user has made an account. Later on the ID is used to search about that profile or update that profile. </p>
  
  <p>Question: Why would I use ID in MySQL when I can search with the username?  </p>
  
  <p>I can use the username to search in a MySQL table too, so what are the pros and cons when using an ID?</p>
  
  <p>UPDATE:</p>
  
  <p>Many thanks for your reactions!
  So let's say a user wants to log in on a website. He will provide an username and password. But for my code I first have to do an query to know the ID, because the user don't know the ID. Is this correct or is there another way to do it?</p>
  
  <p>If I would store the ID of the user in a cookie and when the user logs in then I first look if the ID is the right one with the username. And then checks if the password is correct. Then I can use the ID for queries. Is that an good idea? Of course I will use prepared statements on all of this.</p>