Today I found myself looking at a large amount of information in a database. I wanted to limit the data returned and so I enlisted the help of the substring function. There were thousands of rows of data that contained the word "mapping." I didn't want to see those rows in my query. So I asked the database for all the rows that didn't contain the substring "mapping". That gave me the information I was looking for and I was able to move onto my next project.
I was busily working when a coworker came up and asked me to change the data in another database. She started describing the problem and it sounded like it was going to be a huge task until I realized that it could be simplified with the use of the substring function. Basically I needed to remove the first 4 characters of one database field and replace it with a 5-character word. As I had been using the substring function earlier, the syntax or way of using it, was fresh in my mind. The SQL command looked similar to this:
UPDATE the_table
SET the_field = 'abcde' || substr(the_field,5)
WHERE another_field = 'xyz';
Going through the statement, the first line tells the database what table to update. The last line says we want the update to occur where a specific field is equal to the string "xyz". The second line shows the use of the substring or "substr" function. I didn't care about the first 4 characters of the existing string and so I started at position 5 (SQL strings start at character 1 while C programming language strings start at character 0, which can be confusing). I then concatenate it with the replacement string of "abcde". The two vertical pipe symbols represent the concatenate function in SQL.
The statement worked fine and I was free to get back to my other task. Amazingly I have not had to worry about the substring function for quite a while and I found it interesting that I needed it twice today.
Wednesday, April 13, 2011
Wednesday, April 6, 2011
Unwanted E-mail
Every morning I log into my personal e-mail and have about 25 messages waiting for me. All but about 3 of them are daily broadcasts that I have signed up to receive. Lately I have discovered that I don't really read a lot of them and so I have started unsubscribing from a few.
My real job is dealing with computers and so I have about 10 different e-mails I get on a daily basis related to information technology. About 5 of those are duplicates and so I unsubscribed from half. The other half I find myself gleaming some level of information at least weekly and will continue to sift through them. There are one or two other daily e-mails from places where I purchased goods and so I have opted to be removed from their daily flood of specials.
The interesting thing to me is what I have decided to keep. One of my favorite daily e-mails is from Steep and Cheap. If you are into camping, hiking, skiing, climbing, and just generally hanging around outside, you should sign up for their daily e-mail. They have incredible deals on outdoor equipment and I have managed to get some great skis for a very low price. Furthermore, the guy that writes the daily e-mail is incredibly funny and worth two minutes of my day.
There are the usual messages related to scouting, ham radio, and skiing. Sometimes they are important and other times I delete them without even reading the messages. As I only have a limited time to spend reading e-mail, the fewer messages I get, the more time I have to devote to the e-mails I do read.
My real job is dealing with computers and so I have about 10 different e-mails I get on a daily basis related to information technology. About 5 of those are duplicates and so I unsubscribed from half. The other half I find myself gleaming some level of information at least weekly and will continue to sift through them. There are one or two other daily e-mails from places where I purchased goods and so I have opted to be removed from their daily flood of specials.
The interesting thing to me is what I have decided to keep. One of my favorite daily e-mails is from Steep and Cheap. If you are into camping, hiking, skiing, climbing, and just generally hanging around outside, you should sign up for their daily e-mail. They have incredible deals on outdoor equipment and I have managed to get some great skis for a very low price. Furthermore, the guy that writes the daily e-mail is incredibly funny and worth two minutes of my day.
There are the usual messages related to scouting, ham radio, and skiing. Sometimes they are important and other times I delete them without even reading the messages. As I only have a limited time to spend reading e-mail, the fewer messages I get, the more time I have to devote to the e-mails I do read.
Labels:
backcountry.com,
e-mail,
outdoors,
steep and cheap
Subscribe to:
Posts (Atom)