'returning the LINESTRING of the part of a POLYGON that falls within another POLYGON?

I can see if two POLYGON's intersect with one another using MBRIntersects(g1, g2) but is there a way to return the LINESTRING part of g1 that falls within g2?

Alternatively, if I could get the POINTs of POLYGON g1 that fall within POLYGON g2 it seems like I could create a LINESTRING from that.

Any ideas?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source