title: Convert Points to Polygon using PostGIS
body: <p>I want to create a polygon table using PostGIS. Each row in table '<code>point</code>' has three-point <code>ID.</code>
  Table '<code>point_location</code>' has the location information of points. I googled this question but did not find the answer. What's wrong with the following code?</p>
  
  <pre><code>SELECT ST_GeomFromText('POLYGON((' || b.x || ' ' || b.y || ',' || c.x || ' ' || c.y || ',' || d.x || ' ' || d.y || ',' || b.x || ' ' || b.y'))',4326) 
  AS polygon
  FROM point a, point_location b, point_location c, point_location d
  WHERE a.p1=b.point_id AND a.p2=c.point_id AND a.p3=d.point_id
  </code></pre>