Unless you are making a small knitted item that requires only one skein of yarn, you have to attach a new skein or ball when the first one is finished. There are several ways to do this. Different knitters have conflicting opinions about how to join yarns. A lot depends on what the project is, the type of yarn you are using and where you need to join the yarn.
Here are three ways of tying in at the seam edge.
1) One of the most common ways is to anticipate that there is not enough yarn to complete a row. Attach a new skein at the seam edge before beginning the row by tying a square knot against the needle leaving three or more inches of yarn on both the new and the old. Later these ends are worked into the seam edge.
2) Instead of a square knot, some use a slipknot to tie the new skein to the old. This is my preferred way because I believe the slipknot is more secure and will not come loose easily.
3) There are others that say one should never tie a knot when attaching new yarn. They suggest that one leave long ends of the old and new yarn about four inches and weave them into the seam later.
These are ways to tie in new yarn in the middle of a row.
There are times when it is just not feasible to join yarns at the beginning of the row. For the most part, one should never tie a knot when joining a new skein after a row has been started. There are different ways to join the yarn without tying the ends.
1) Perhaps the best method is to splice the two yarns together. You do this is by unraveling the yarn for about an inch or two on both ends. Then twist the strands around each other to form a single strand similar to the original yarn. If there are ends left after the yarn is twisted, do not cut them. Later weave them in so they do not unravel and show through on the right side of the work.
2) If you think unraveling and twisting the ends of the yarn is too much trouble, another way to splice is to take a tapestry needle and thread the new yarn into it. Insert the needle with the new yarn into the end of the old yarn for about three inches. Leave a short end on the wrong side to weave in later.
3) If the yarn cannot be spliced, such as nubby or very thin yarn, leave a four inch end of old yarn, work a few stitches with the new yarn, leaving a four inch end. After a few rows you can weave these ends into the work.
4) Yarn that is fine and cannot be spliced can be joined by overlapping the two ends of yarn or thread for about six inches. Work for six or eight stitches with the double yarn. On the next row work them as a single stitch. It is best if this method of joining is done in as inconspicuous a place as possible.
After you have been knitting for a while, you will be able to choose the method of joining that best meets your needs. You will find that the project and type of yarn you are using determines which way you join your yarn.