0

I'm trying to insert data from one table to another, but I keep getting a weird SQL error. The following is my query along with the error.

insert into hs.hs (`field1`,`field2`,`field3`)  select cid,sid,'1' from `tmp1`;

now the error

1416 - Cannot get geometry object from data you send to the GEOMETRY field.

I don't understand why I'm getting a geometry error there is no geometry involved at all.

By the way my MySQL version is:

SELECT VERSION();  Result 5.7.16-log

I'm pretty sure I'm doing everything right; Can some one please tell me what I'm doing wrong? Could this be a bug?

Thanks I'm looking forward to some help.

9
  • Try this - insert into hs (field1,field2,field3) select cid , sid, '1' from tmp1; Commented Feb 23, 2018 at 11:52
  • Post the outputs off SHOW CREAtE TABLE hs and SHOW CREATE TABLE tmp1 Commented Feb 23, 2018 at 11:54
  • @kiti I just tryed it same error. Commented Feb 23, 2018 at 12:03
  • @RaymondNijland I just did a show create table all fields I'm querying are int. Commented Feb 23, 2018 at 12:05
  • Please mention all the columns contained in both the tables. Its working well for me, as my "hs" table contains 3 fields. If your "hs" table contains more fields then either you have to assign them values by fetching from other table or give them some default values Commented Feb 23, 2018 at 12:06

2 Answers 2

3

You can try this -

insert into hs (field1,field2,field3) select cid , sid, '1' from tmp1;

If this wont work then try please check the columns contained in both the tables. If your "hs" table contains more fields then either you have to assign them values by fetching from other table or give them some default values.

Sign up to request clarification or add additional context in comments.

Comments

0
insert into hs (field1,field2,field3) select cid , sid, '1' from tmp1;

Below is the reason why the above query didn't worked

  • INSERT INTO SELECT requires that data types in source and target tables match
  • INSERT statement should contain all columns or they should have some default value assigned

Comments

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.