0

I am new to SQL. I am stuck on the error for a while, I hope some one could help me.

update roads1f set indoorpathway=PathWay1f.Indoor_pathway where astext(roads1f.geometry)= astext(PathWay1f.Geometry)

The error is

no such column PathWay1f.Indoor_pathway

I checked PathWay1f table, it has Indoor_pathway column. Did I use the wrong method to reference data in another table?

PathWay1f and roads1f are almost same. The geometry can be considered as the primary key. PathWay1f has a column Indoor_pathway, but roads1f doesn't have. I just want to copy Indoor_pathway from PathWay1f to roads1f.

3
  • Can you provide the definitions of both roads1f and PathWay1f? Are you selecting data from PathWay1f? Where is the portion of your statement that is collecting the data to use for the update? Commented Aug 14, 2017 at 16:56
  • You need a FROM clause referencing the Pathway1f table. Commented Aug 14, 2017 at 17:00
  • Actually, PathWay1f and roads1f are almost same. The geometry can be considered as the primary key. PathWay1f has a column Indoor_pathway, but roads1f doesn't have. I just want to copy Indoor_pathway from PathWay1f to roads1f. @gmiley Commented Aug 14, 2017 at 17:21

1 Answer 1

2

You need the join

update roads1f 
set indoorpathway=( 
        select PathWay1f.Indoor_pathway  
        from PathWay1f
        where astext(roads1f.geometry)= astext(PathWay1f.Geometry))
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks! It looks like good, but it takes very long time, and haven't finished yet.. My roads1f table has 50,000 rows. Does it take O(n^2)?
you have posted a question about an error .. not for performance .. if you have 50.000 the performance depend by several fatcor .. indexes ... hardware .. and others ..and . if you have not the error this mean that my answer should be right then you should rate the asnwer properly ..
@chen When the code does what it basically is supposed to do (after using scaisEdge proposal) then it is time to either ask a separate specific code question (as scaisEdge implied) with speed aspect here at StackOverflow, or to switch to codereview.stackexchange.com
@scaisEdge Thanks! My apology.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.