Query get tables

Implements #30, #37 and #38.