I’m trying to do some work with my SQL table.
I have 2 buildings with room numbers 1 – 100 in building 1 and 101 – 199 in building 2.
I have a location field (which I’ve just created) and want to run a query to populate it with either ‘Building 1’ or ‘Building 2’ depending on which room number it has in the ‘Room’ field.
Many thanks for your help.
Regards
Scott
You can use
Caseto update your table:If all of your room-numbers have three digits followed by some other characters, using
substringshould work:Since not all of your rooms start with three digits (
1A) you can usePatIndexto find the length of the number:I’m concatenating the
Ato make sure it also works with numerical room-numbers.