Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8769275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:17:57+00:00 2026-06-13T17:17:57+00:00

I have create a table using create table and with these column: create table

  • 0

I have create a table using create table and with these column:

create table myschema.mytable(
    id serial PRIMARY KEY, 
    row_num integer, 
    col_num integer, 
    pix_centroid geometry, 
    pix_val double precision
)

When I am trying to populate it:

insert into pixelbased (id, row_num, col_num, pix_centroid, pix_val)
values (
    DEFAULT, 
    (select((ST_PixelAsPolygons(rast, 1)).x)  from mytable where rid=3),  
    (select((ST_PixelAsPolygons(rast, 1)).x)  from mytable where rid=3), 
    (select(ST_Centroid((ST_PixelAsPolygons(rast, 1)).geom)) from rwanda8 where rid=3),
    (select(ST_PixelAsPolygons(rast, 1)).val from mytable where rid=3)
) 

I am encountered with the following error:

ERROR: more than one row returned by a subquery used as an expression.

I know that since I have more than one row for every column it does make sense to have such an error. But I really need to have all the columns calculated as mentioned. Anyone knows what should I do?
In fact I want to insert the result the following query in the table:

select 
    (ST_PixelAsPolygons(rast, 1)).val as geomval1, 
    (ST_PixelAsPolygons(rast, 1)).x as X, 
    (ST_PixelAsPolygons(rast, 1)).y as Y, 
    (ST_Centroid((ST_PixelAsPolygons(rast, 1)).geom)) as geom 
from rwanda8 
where rid=3

Anyone knows what should I do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:17:59+00:00Added an answer on June 13, 2026 at 5:17 pm

    Just use the select query in instead of the values

    insert into pixelbased (row_num, col_num, pix_centroid, pix_val)
    select
        (ST_PixelAsPolygons(rast, 1)).val as geomval1,
        (ST_PixelAsPolygons(rast, 1)).x as X,
        (ST_PixelAsPolygons(rast, 1)).y as Y,
        (ST_Centroid((ST_PixelAsPolygons(rast, 1)).geom)) as geom
    from rwanda8 where rid=3
    

    Do not insert the id as it is a serial and will generate itself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have these tables: create table Person ( PersonId int identity(1,1) primary key, PersonName
I have to create one table using XSLT and CSS. The table should look
I have created one table using the below command: create table Table1( Id int
I am using luasql. I have two tables of this type: IPINFO CREATE TABLE
Create Table A ( ID varchar(8), Primary Key(ID) ); Create Table B ( ID
I am using T/SQL in Microsoft SQL Server 2008 I have a table CREATE
I am trying to create a column in a table that's a foreign key,
I'm trying to follow http://www.foliotek.com/devblog/make-table-rows-sortable-using-jquery-ui-sortable/ And have created a very simple example http://jsfiddle.net/6wbZQ/ It's
I have created many tables using <table> tag but don't know how to get
I have a table created in sql. but in my application I am using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.