The rule here is that the following prepositions take the accusative case when there is movement/change of place involved, and the dative when there is no movement or change of place.
| an | at, on up to | neben | next to, near |
| auf | on, on top of | über | over, above, across |
| hinter | behind | unter | among |
| in | in, into, to | vor | in front of, outside |
| zwischen | between |
Leg das Buch auf den Tisch und nicht in den Schrank, bitte. - Put the book on (to) the table and not in(to) the cupboard, please. (accusative for both, as movement is involved)
Ich habe das Buch auf dem Tisch im Wohnzimmer gefunden. - I found the book on the table in the living room. (dative, as no movement is involved)
Die Katze schläft auf dem Stuhl. - The cat is sleeping on the chair. (dative, as no movement is involved)
Ich gehe jedes Wochenende ins Kino. - I go to the cinema every weekend. (accusative, as movement is involved)
Vati ist in der Küche und Mutti ist in den Garten gegangen. - Dad is in the kitchen and Mum has gone into the garden. (dative for Dad, as no movement is involved; accusative for Mum, as movement is involved)