Combining a query for value and an insert MySQL
Use INSERT .. SELECT instead of INSERT .. VALUES:

INSERT INTO accounts (name       , login       , ..., rank        , ...)
SELECT                'some name', 'some login', ..., ranks.rankID, ...
FROM ranks
WHERE ranks.name = 'some rank' /* ORDER BY ranks.somefield LIMIT 1 */


The values You need to insert directly (name, login, etc.) are added into SELECT part literally, the data obtained from ranks table is selected by common way. If there exists more than 1 record in ranks appropriate to criteria You use - add ordering and limiting to select (and add into destination table) one record only.