Magento 2 How to create custom query that is the question sometime is popped up on your head. Here is how I create my own custom queries in Magento 2.
Currently, I figured out two ways :

1/ Take advantage of using Magento Resource Connection.

You can change the query to insert, update or delete according to zend framework. It’s just an example code, you should put $connection in a  property of a helper class and use it from this help class.

2/The other way is reusing Magento Object Manager to create a collection:

Happy coding !