Although lamps come in all sizes, shapes and colors, their electrical components are pretty much the same. Usually there are five: the socket, the cord, the switch, the plug and the conduit. The conduit is a threaded metal tube that serves two purposes. It is used to safely carry the power cord from the bottom of the lamp up through the inside to the socket, and to hold the socket, the lamp body and the base together. So, should you undertake a lamp repair, make sure to treat this part with special care. Loosening it without caution could cause a broken lamp base or body.
CAUTION: Before working on an electric appliance make sure to unplug it. Since the lamp switch is the only moving component, it is the part that most often fails. If the switch is separate from the socket, and in the base, the repair is usually easy. Remove the wires, remove and replace the switch, and reconnect the wires. Some lamp bases have a felt covering on the bottom that has to be peeled back in order to gain access to the inside. Use a putty knife to slowly separate the felt from the base. A dab of white glue can be used to reattach the felt after the repair is made. Don't put the lamp back on a table until the glue is completely dry.
If the switch is in the socket, the repair job is a bit more tricky, but as home improvements go, still relatively simple. Fortunately, light sockets for lamps are all much the same. There are three different kinds of light socket switches: the pull-chain, the push-button and the rotating-knob. There is no particular advantage to one over another.
Lamp sockets are universal in nature, regardless of the type of switch. So, if you desire, the switch can be changed to a different type as part of the repair. An upgrade repair, if you will.
To replace the socket it must first be disassembled so that it can be disconnected from the cord. This is the same process used to change the cord. The top and base of the socket are inter-connected by corrugations at their perimeter. By pressing or squeezing the upper section (near the corrugations) while pulling at the same time, the socket can be opened to expose the screws that hold the cord wires in place. Remove the wires by loosening the retaining screws, untie the knot in the wire and then remove the base of the socket by loosening its set screw, and unscrew it from the conduit. Be careful. This can be dangerous if you are not. Once the set screw is loosened and you begin to unscrew the socket base, you are loosening the main connecting device that holds the entire lamp together. Again, be careful.
To install a new socket simply reverse the process. This is a good time to change the cord if it is worn or you want one in a different color. If you decide to install a new cord you will probably need to replace the plug. For best results, use a press-and-lock plug. It is inexpensive, well-insulated, and easy to attach.
If you have a lamp that you want to upgrade to three-way operation, make sure that your socket includes a three-way switch. Not all do.