They both cause tides. The lunar tides are higher than the solar ones.
When the Moon and Sun are on the same side or on opposite sides of the Earth then they work together, and you get the "spring tides" which are especially high and especially low.
This happens every 14 days when the sun and Moon are roughly in the same spot in the sky and then again when they are opposite each other
Side note: these times of the spring tides are also the times in the lunar month when you get solar eclipses, and lunar eclipses respectively - though - those need a more precise alignment than tides. Eclipses only happen in the "Eclipse seasons" which lasts between 31 and 37 days, and occurs every 173 days, just short of six months. Since the lunar month of 28 days is shorter than the eclipse season, we are guaranteed at least one lunar and one solar partial eclipse every six moonths, though total eclipses are rarer. Lunar eclipses are visible anywhere on the nighth side of Earth at the time it occurs, but solar eclipses are only visible from the places that the shadow of the Moon passes over. See Eclipse Statistics.
When the Moon and Sun are at right angles to each other as seen from the Earth you get the neap tides which are much less extreme because the sun tide counteracts the effect of the lunar tide instead of working together with it
(see also schoolphysics ::Tides)
Here is an animation of the spring and neap tides
Animation of spring and neap tides - the spring tides happen when the solar and lunar bulges are in the same position.
If you live near the sea, as one of my sisters does - you can see this easily. Every two weeks you get really high tides, and then they go really low as well so you can walk out for a long distance - and the river mouth outside her house nearly dries out completely at the lowest tides on the spring tides.
Also - the tides get later every day, by a little under half an hour each day.
As Arun Prasath explained - then when the Moon is overhead it causes a tidal bulge on the same side as the Moon and the opposite side of the Moon.
So, in the simplest case, the tides happen soon after the Moon passes directly overhead - so that you'd get the spring tides at midday and midnight. The neap tides, caused when the Moon is at right angles to the sun - they happen at 6 a.m. and 6 p.m.
However it is rarely as simple as that. Reason is because of the shape of the land. Tides start in the open sea, but then they have to weave in and out of the land masses. Here on the West Coast of Scotland, inner hebrides especially - then some of the islands are really close to the mainland with narrow inlets in between with strong tidal "rips" strong currents as the tides move around the island. And East coast of Scotland has a different tide time from the West coast.
Here for instance are some of the tide tables for the West coast of Scotland
BBC Weather - Tide Tables - Oban
Try comparing a few different places - e.g. (as of writing this - obviously will depend when you read this) - Stornaway tomorrow has high tide at 1620 while Rosyth has high tide at 1147.
In fact, the North sea coast actually gets its tides two days later than the open Atlantic - their Spring tides don't happen at full Moon, but two days after full Moon, because it takes that long for the tidal "wave" to get there.
North Sea - photo by NASA. Surrounded on all sides by UK, Holland, Denmark, Sweden and Norway. The North Sea has its high tide two days later than the open Atlantic, for instance its spring tides - the highest tides - happen two days after full Moon. That’s because it takes that long for the tidal “wave” to get there. It takes it six hours just to traverse the English Channel - the East end of the channel experiences high tide when the West end experiences low tide and vice versa. Because of its complex coastline then many parts of the UK are like that. Coastal places quite close to each other can have tides hours apart.
On this chart, the white lines are "cotidal" lines - all the places along those lines experience the spring tides at the same time.
Amplitude is indicated by color, and the white lines are cotidal differing by 1 hr. The curved arcs around the amphidromic points show the direction of the tides, each indicating a synchronized 6 hour period.
And - some parts of the world have only one tide rather than two.
Here the places with diurnal tides - so just one tide a day - are marked in yellow. The ones with two high tides a day are marked with red coastlines, and others shown in blue have mixed tides somewhere between the two. See NOAA's National Ocean Service: Low tide
In the English Channel you get a curious phenomenon of the “double high tide” at Southhampton, for instance, the high tide “stands” for a long time with a slight reduction of the tide levels in the middle. It’s because of the English Channel - the tides around the UK set up an oscillation such that when it is high tide at one end of the channel it is low tide at the other and vice versa. South Hampton is right in the middle and the oscillation sets up other smaller oscillations which cause the double tide phenomenon. Explanation here: English Channel Double Tides
This animation supposedly shows it though I don’t find it easy to read bu tyou can see the oscillation clearly enough with high tide at one end and low tide at the other end of the channel. Here red is high tide and blue is low tide.
But - at any particular place, the spring tides are always at roughly the same time. So for instance if you get diurnal tides, and with your highest tides at midday and midnight, then every 14 days you will get your highest tides at the same place at those same times. If you get your highest tides at 4 pm and 4 am, then again every 14 days you get them at the same time. And the low tides 6 hours later.
So - for someone who doesn't live by the sea, the tides seem unpredictable. But if you live at some particular location close to the sea, and if you can see the sea - and especially if you have need to go out and do things that depend on knowing the tides - then you soon get to know how the tides work wherever it is you live. Especially, you get to know what time of day the spring tides happen for your area - both the high and the low tides. And once you know that, and if you know the phase of the Moon, it's not too hard to work out when the high and low tides are any time of the lunar month.
There are other factors as well. The Earth and Moon don't follow perfectly circular orbits and the height of a tide varies as the inverse cube of the distance to the gravitating body - so small changes in distance can make a significant difference to the height of the tide.
The highest spring tides occur when the Moon and Sun are both at or near their closest points to the Earth. Earth is closest to the sun around 2nd January, so highest spring tides are in winter. If accompanied by a storm, they will be even higher. It is furthest away around 2nd July so the lowest tides are in summer.
The position of the Moon in its cycle is also relevant. The Moon has a complex continually changing orbit, but is closest to the Earth (perigee) every 29 days. - the so called Supermoon. So when this coincides with the perihelion (when Earth is closest to sun) the tides are at their highest.
Then storms far out at sea and other weather effects can increase the height of the highest tides.
Aftermath of a King tide
Actually - where I live now I'm - I think less than a mile from the sea - but I can't see it from my house, and don't go down to the sea shore often enough to have got used to how the tides work - could easily look them up but don't kind of know them by heart. So I don't know what time of day the spring tides are here actually. But if I lived in the village down by the sea shore less than a mile away - I would probably be well aware of what the tides are.
Wikipedia has a good article on tides:
See also Misconceptions about tides.