I have 2 tables - Rawdata and Cleandata

Rawdata gets regulary id's and distances

```
INSERT INTO rawdata (`ShuttleID`, `Distance`) VALUES ('1', '50');
INSERT INTO rawdata (`ShuttleID`, `Distance`) VALUES ('1', '50');
INSERT INTO rawdata (`ShuttleID`, `Distance`) VALUES ('2', '100');
INSERT INTO rawdata (`ShuttleID`, `Distance`) VALUES ('2', '100');

```

Cleandata has only one id.

```
INSERT INTO cleandata (`ShuttleID`, `Distance`) VALUES ('1', '0');
INSERT INTO cleandata (`ShuttleID`, `Distance`) VALUES ('2', '0');

```

There will be alot of entries in rawdata. My idea is to sum(Distance) and use UPDATE to the Distance in cleandata.

```
UPDATE cleandata cd, rawdata rd SET cd.Distance = cd.Distance + (SELECT sum(Distance) FROM rawdata GROUP BY ShuttleID)

```

My Query is working when i am placing only one ShuttleID. If i place more ID's i get the error

**Error Code: 1242. Subquery returns more than 1 row**

I understand it because the Select statement gives me more rows when i have more id's

My question right now is : How can i alocate the correct Distance from Rawdata to Cleandata?