Archive for January, 2008

How To Make Update Statements From phpMyAdmin

I figured out this cool trick today: how to make update statements straight from phpMyAdmin. The normal way I go about this is either to write them using php or to do them using regular expressions in Notepad++. However, both of those can be kind of time consuming.

Today I needed to update one table with values from another table (replacing a last name with an id). Here is a simple version of how the tables are laid out:

Table 1 (counties)
id | person | county

Table 2 (people)
id | lastname | firstname | address

Table 1 had the person’s last name in the `person` field and that needed to be changed to the `id` of the person (in case the last name changed). To do that, I did a select statement with a concat() function in phpMyAdmin:

SELECT concat( ‘UPDATE counties SET person=\”, id, ‘\’ WHERE person LIKE \”, lastname, ‘\’;’ ) FROM `people`

The output from that statement created the all of the update statements I needed and I copied and pasted those right into the sql input box. Wha-la, almost instant update statements with no php middle man.

I think you can also do this with update statement using a join to automatically update one table from another, but I didn’t feel like doing a Google search :) Maybe that will be another post, but if anyone cares to comment on that, that would be cool.

if you liked this post :)

Category: Programming | 387 views | Posted: January 4th 2008 05:16 pm

Related Posts

Top Commentators Beat the Crap out of Do Follow

Yeah, I couldn’t believe it either. I got on my blog today and noticed the Do Follow plugin was in serious bad shape. As I looked around, I caught the new kid on the block, Show Top Commentators, red handed…literally…bloody knuckels and all. Since Do Follow was obviously down for the count, and STC wasn’t backing down, all I could do was award him the top seat in the sidebar. So there he sits, on the sidebar of every page, waiting for your comments. Use him wisely.

I couldn’t leave STC off the hook without some method of recourse so I gave him a swift kick in the nuts to remember me by. That reconfigured his source a bit so we’ll see how he shows up now. Nobody messes with the General.

if you liked this post :)

Category: Announcements | 339 views | Posted: January 3rd 2008 05:01 pm

Related Posts

Remember to Search for Promo Codes

I figured out a little trick to save some cash when buying things like domain names, hosting, printing, dinner plates, etc on the internet and wanted to share it. Any time you buy something online and see a coupon code input field when you are checking out, make sure you do a Google search for ’store name’ and ‘coupon code’ or ‘promo code’. There are tons of websites that collect and share this information and they can offer you some great savings. For example - the next time you buy a domain name from GoDaddy (www.GoDaddy.com), search for ‘godaddy coupons’ on Google and you’ll get lots of sites offering codes for things like 10% off and $6.95 domain names.

if you liked this post :)

Category: General | 559 views | Posted: January 2nd 2008 12:34 am

Related Posts

« Prev