MySQL Selection Help

When you’re selecting a username and password from your database, how do you write your PHP script where it selects the correct user_id for that username and password? Or does the database do it for you when you tell it which username and password to retrieve in the WHERE clause (provided you write the query to retrieve the user_id as well, of course).

You’d have to retrieve that yourself, using a select, eg:

SELECT user_id FROM user WHERE username =‘fred’ AND password=‘flintstone’;

(or similar!)