Merging two tables in mysql

This is something I occasionally want to do, but I have usually forgotten how to do it, so the recipe goes here on the back of my giant online envelope.

There are two ways to merge two tables. One involves using a union clause. This way the tables stay separate, but can be handled as one in any searches or data munging.

The other way is to actually modify one of the tables. This has at least one feature that a union clause does not: it can produce a unique id number for all the records in the merged table. This is something I often want, so today’s recipe covers how to do that.

The main reason that I have problems with a merge is because I use auto-increment to produce a unique key for each record. Call this the primary key. Of course when you merge two tables produced this way, their primary keys clash.

Assume that the tables have identical structure. Call the table that you want to hold the result of the merge table A. Call the table you want to merge into A table B. Call the primary key on both tables id. To merge B into A:

1) create table btemp select * from b (create temp table with no primary index)
2) update Btemp set id = 0 (This is okay because temp table has no primary index)
3) insert into A select * from btemp

mysql will insert all records from b, continuing with the auto-inc numbering for the primary key a.id

Posted in Programming | Comments Off on Merging two tables in mysql

Welcome to the Fall semester, 2024

Dear students,

A late welcome to the new semester! I’m teaching two courses this semester at National Chi Nan University’s Department of Foreign Languages and Literature. Both are on NCNU’s Moodle site, please check there for class details. My school email is also available there in case you have any questions or comments.

This blog is mostly on my outside interests, though it also does sometimes have stuff on translation. Feel free to take a look here if you are interested in what I’m doing outside class. For non-student readers of the blog, I hope there is something interesting here for you too!

Posted in Uncategorized | Comments Off on Welcome to the Fall semester, 2024

Lighthouses in Wisconsin

Another video from our son Nick. Love these old towers!

Posted in Quotidiana | Comments Off on Lighthouses in Wisconsin

Happy Summer 2024!

Well that year went by fast! Classes are now long done, and it was a good semester–all pass! Also, congratulations to my graduate student advisee, Ivan Mak, who successfully defended his thesis in June 2024 and is now on his way to a new job in Singapore.

I have a few new books I’ve read that I may post about, otherwise I am mostly writing for my other blog at jfkarc.info and may have articles up at other places, depending on how lazy I am. Any new posts/publications will get notice here. Enjoy the summer!

Posted in School | Comments Off on Happy Summer 2024!

Welcome to the fall semester, 2023!

Dear students,

Welcome to the new semester! I’m teaching two courses this semester at National Chi Nan University’s Depatment of Foreign Languages and Literatures, both have class pages on NCNU’s Moodle site, please check there for class details. My school email is also available there in case you have any questions or comments.

This blog has irregular notes on my outside interests, though it also does sometimes have stuff on translation, and now on Bible literature as well. Feel free to take a look here if you are interested in what I’m doing outside class.

Looking forward to seeing you all in class, and a happy Mid-autumn festival to you all!

Posted in School | Comments Off on Welcome to the fall semester, 2023!

Review of Killing the dream

Gerald Posner Killing the Dream. Little & Brown, 1998.

Killing the Dream is the second book by Gerald Posner to tackle a major political assassination. His first assassination opus, Case Closed, was published in 1993 and took a close look at the murder of President John F. Kennedy 30 years after his death. Posner made a strong case for Lee Harvey Oswald as the lone gunman, with no conspiracy behind his actions. Killing the Dream was published five years later, in 1998, and likewise argues that James Earl Ray fired the shot that killed Dr. King on April 4, 1968, and that Ray planned the assassination without significant help from others, though he does not rule out the possibility that Ray’s brother Jerry may have known of the plan beforehand.

Like Case Closed, Killing the Dream is well-written and thoroughly researched. The MLK assassination has a long legal history, been the subject of a major government investigation, and spawned dozens of books. Posner’s book does not, cannot, summarize all of this, but it is still a helpful introduction to the history and literature of the subject. This is not a minor virtue. Like the JFK assassination, the accretions of controversy have made it harder and harder to master the ever expanding web woven around Dr. King’s death, especially the conspiracist writings and theorizing, which are often poorly documented and difficult to understand.

Posner gives a valuable summary of the literature that has grown up around the King murder, and of the major legal developments up until 1998. For those who want to know who wrote and claimed what, there are few other works that go over this ground. This contrasts with the JFK assassination, where there have been multiple attempts to summarize at least parts of the case and the network of investigations that have been woven about the event.

More history and literature has continued to grow, barnacle-like, around the King case since Killing the Dream. was published, so Posner’s book is not the end of the story. To summarize this later material might well take another book.

Posted in Book reviews | Comments Off on Review of Killing the dream

Cormac McCarthy, 1933-2023

Cormac McCarthy was one of the best American novelists of the last 50 years. Despite his sometimes difficult style, I’ve taught him in writing, literature, and translation classes. There are, however, suprisingly few Chinese translations of his works. The Road is perhaps the easiest one to find, published in Taiwan as 長路 by 麥田.

His other books, especially the early ones, are harder to find in Chinese. Japanese translations are more numerous, though apparently Outer Dark and Suttree are still untranslated, and The Orchard Keeper was only translated into Japanese last year. Like Faulkner, McCarthy has had little luck with either translators or publishers in East Asia.

Posted in Literature | Comments Off on Cormac McCarthy, 1933-2023

Spring semester 2023 update

Hello to my students and other visitors,

My apologies for the neglected look of this blog. I had a semi=major software update issue that took quite a while to resolve. The cite now appears to be working again, and I hope such major updates will go more smoothly next time. It’s hard to keep up with some of these things, since my major interest and competence is not in internet programming and software.

The spring semester sprang four months ago and is now at the tail end. I have enjoyed this semester a great deal, and I hope it has been useful to you all. Teaching as an adjunct takes some of the pressure off, and leaves more room for the learning stuff. Always a good thing.

More things will appear soon on this website. I hope to put up a few reminiscences of some of my teachers who passed away in the last year. I was fortunate to study at National Taiwan University when these outstanding scholars were there, and although my research has since meandered away from some of these subjects, I still remember and value much of what I learned from them.

I also hope to put up some more research papers. Although I’m doing less and less as time goes on, some of it may still be valuable to someone out there interested in classical Chinese syntax and so on. I also have some more recent material on Chinese bible translation and interpretation that I expect will be out this year, in one format or another.

In the meantime, good luck and keep on pushing as the semester marches to an end!

Posted in School | Comments Off on Spring semester 2023 update

Welcome to fall semester!

Back in Puli, and classes have started. All is going well, except that I’m busy moving lots of books! For friends and students who did not know, I am now an adjunct professor, following my retirement this summer. I’m glad to still be teaching and feel lucky to continue as part of the Department of Foreign Languages and Literature at Chi Nan!

Posted in School | Comments Off on Welcome to fall semester!

Summer, 2022

Summertime and we are back in the U.S. for the first time in 3 years. Always pleasant up north here where our guys are, especially compared to the tropicalness of Taiwan, but I’m sure some of my students and colleagues are enjoying the mountains of Nantou county as well. We will be back in September, hopefully having classroom classes again. Internet instruction doesn’t really do it for me, but we will do what is necessary. Hope to do a few posts before then. We’ll see how that goes, I guess.

Posted in Quotidiana | Comments Off on Summer, 2022