0

My table looks like this:

id   city         road_id
-------------------------
1    london       3
2    manchester   3
3    newcastle    3
4    glasgow      3
5    london       5
6    newcastle    5

I know values of two cities and road_id and need something like this:

UPDATE table SET anothercolumn=1 WHERE id>=(id for)london AND id<(id for)glasgow AND road_id=3

to affect only these rows:
1    london       3
2    manchester   3
3    newcastle    3
1
  • So you want to select (in this case, for update) the rows with the id between id(London, inclusive) and id(Glasgow, exclusive)--rather than cities with names between "London" and "Glasgow"? Commented Dec 14, 2014 at 22:13

1 Answer 1

1
UPDATE your_table 
SET anothercolumn = 1 
WHERE id >= (select id from your_table where city = 'london')
AND   id <  (select id from your_table where city = 'glasgow')
AND road_id = 3
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.