The 15-bookshelf rule
The table's maximum offer scales with nearby bookshelves: every two bookshelves adds one level to the cap, up to 15 bookshelves for a level-30 maximum. Place bookshelves in a ring one block away from the table with a two-block gap, at the same height or one above, with air in between — a bookshelf touching the table or blocked by another block does not count.
Lapis and the three offers
Each use costs 1 lapis for the first slot, 2 for the second and 3 for the third, plus the experience levels shown. The three offers are three different enchantment rolls; you can take one per item. If none suit you, enchant a cheap item like a wooden shovel to reroll the table's seed.
What you cannot get from the table
Some enchantments are 'treasure' enchantments and never appear in the table: Mending, Frost Walker, Soul Speed, Swift Sneak and Wind Burst among them. Those come from librarian trades, fishing, loot chests, ancient cities or piglin bartering.
- Mending — librarian, fishing, loot
- Frost Walker — librarian, fishing, loot
- Soul Speed — piglin bartering
- Swift Sneak — Ancient City loot
- Wind Burst — trial chamber loot
Level 30 is not the same as the best enchantment
A level-30 offer rolls from the full pool for that item, but it still might not be the enchantment you want, and it can be a lower tier of one. Enchanting is gambling; the reliable route to a specific max-level book is a librarian villager, and the reliable route to a cheap anvil order is planning the combination before you start.