protected function buildTables($with_alias=true) {
		$tables = [];
		$params = [];
		if(!$this->tables)
			throw new \Exception('Must set tables with method from($tables) before running the query.');
		foreach($this->tables as $alias=>$table) {
			if($table instanceof static) {
				$tables[] = '('.$table->buildSQL().') '.$this->quote.$alias.$this->quote;
				$params = array_merge($params, $table->getParameters());
			}
			elseif($table instanceof Raw) {
				$tables[] = '('.$table->getSQL().') '.$this->quote.$alias.$this->quote;
				$params = array_merge($params, $table->getParameters());
			}
			elseif($alias !== $table && $with_alias)
				$tables[] = $this->quote.$table.$this->quote.' '.$this->quote.$alias.$this->quote;
			else
				$tables[] = $this->quote.$table.$this->quote;
		}
		$sql = implode(', ', $tables);
		return [$sql, $params];
	}