If it was me, I'd do it manually - but using $wpdb->prepare()
for safety.
My reason for that is that it makes it a lot easier to debug if (when...) I get a table name/alias/value/etc wrong and something doesn't work the way that it's expected. It also gives you a great deal more freedom to do what you need to rather than being stifled by the WordPress-based syntax that you're using now. The various $wpdb
functions are great for general and easy queries, but when you get something that's complicated, it's normally easier to do things in raw SQL code.