Check if the SELECT query has join operation
761489
public static boolean hasJoinOperation(String selectQuery) {
    if (selectQuery == null || selectQuery.length() == 0) {
      return false;
    }

    SqlParser sqlParser = SqlParser.create(selectQuery);
    try {

      SqlNode all = sqlParser.parseQuery();
      SqlSelect query;
      if (all instanceof SqlSelect) {
        query = (SqlSelect) all;
      } else if (all instanceof SqlOrderBy) {
        query = (SqlSelect) ((SqlOrderBy) all).query;
      } else {
        throw new UnsupportedOperationException("The select query is type of " + all.getClass() + " which is not supported here");
      }
      return query.getFrom().getKind() == SqlKind.JOIN;
    } catch (SqlParseException e) {
      return false;
    }
  }
84406
function joinQuery(queryObj, skipEmpties)
{
	var i,len,value,varname;
	var count = { i:0 };  // literals do not persist across functions
	var output = "";
	
	for (varname in queryObj)
	{
		if (queryObj.hasOwnProperty(varname)===true)
		{
			value = queryObj[varname];
			
			// "?var1=a&var1=b" would've been parsed to { var1: ["a","b"] }
			if (Array.isArray(value) === false)
			{
				output += joinValue(varname, value, count, skipEmpties);
			}
			else
			{
				len = value.length;
				
				for (i=0; i<len; i++)
				{
					output += joinValue(varname, value[i], count, skipEmpties);
				}
			}
		}
	}
	
	return output;
}
1152513
static boolean isGroupByColumn(QuerySpecification select, int index) {
        if (!select.isGrouped) {
            return false;
        }
        for (int ii = 0; ii < select.groupIndex.getColumnCount(); ii++) {
            if (index == select.groupIndex.getColumns()[ii]) {
                return true;
            }
        }
        return false;
    }
844966
public function hasJoin($aliasOrTable)
    {
        if ($this->join) {
            foreach ($this->join as $join) {
                $secondJoinParam = $join[1];
                if (is_array($secondJoinParam)) {
                    list($key, $val) = each($secondJoinParam);
                    if ($key == $aliasOrTable) {
                        return true;
                    }
                }
                if (is_string($secondJoinParam)) {
                    if ($secondJoinParam == $aliasOrTable) {
                        return true;
                    } else {
                        $pos = strrpos($secondJoinParam, ' ');
                        if ($pos) {
                            $alias = substr($secondJoinParam, $pos);
                            $alias = trim($alias, " \t`");
                            $table = substr($secondJoinParam, 0, $pos);
                            $table = trim($table);

                            if ($alias == $aliasOrTable || $table == $aliasOrTable) {
                                return true;
                            }
                        }
                    }
                }
            }
        }
        return false;
    }
545773
function _join() {
    var sql = '',
        i = -1,
        joins = this.grouped.join;
    if (!joins) {
      return '';
    }
    while (++i < joins.length) {
      var join = joins[i];
      if (i > 0) {
        sql += ' ';
      }
      if (join.joinType === 'raw') {
        sql += this.formatter.unwrapRaw(join.table);
      } else {
        sql += join.joinType + ' join ' + this.formatter.wrap(join.table);
        var ii = -1;
        while (++ii < join.clauses.length) {
          var clause = join.clauses[ii];
          sql += ' ' + (ii > 0 ? clause[0] : clause[1]) + ' ';
          sql += this.formatter.wrap(clause[2]);
          if (clause[3]) {
            sql += ' ' + this.formatter.operator(clause[3]);
          }
          if (clause[4]) {
            sql += ' ' + this.formatter.wrap(clause[4]);
          }
        }
      }
    }
    return sql;
  }
40281
def view_exists?(query)
      if query.nil?
        raise ArgumentError, 'Query cannot be nil'
      end

      result = query(query)

      !result.empty?
    end
389440
function where() {
    var wheres = this.grouped.where;
    if (!wheres) {
      return undefined;
    }
    var i = -1,
        sql = [];
    while (++i < wheres.length) {
      var stmt = wheres[i];
      var val = this[stmt.type](stmt);
      if (val) {
        if (sql.length === 0) {
          sql[0] = 'where';
        } else {
          sql.push(stmt.bool);
        }
        sql.push(val);
      }
    }
    return sql.length > 1 ? sql.join(' ') : '';
  }
174021
def query_starts_with(query, prefixes):
    """"""
    prefixes = [prefix.lower() for prefix in prefixes]
    formatted_sql = sqlparse.format(query.lower(), strip_comments=True)
    return bool(formatted_sql) and formatted_sql.split()[0] in prefixes
959852
@NonNull
    @Override
    public Joins join(@NonNull Join... joins) {
        if (joins == null) {
            throw new IllegalArgumentException("joins cannot be null.");
        }
        return new Joins(this, Arrays.asList(joins));
    }
1018708
private boolean isSuccessful(String sql) throws SQLException {
        Statement statement = connection.createStatement();
        try {
            statement.execute(substitute(sql));
        } catch (SQLException e) {
            return false;
        } finally {
            DbUtils.closeQuietly(statement);
        }
        return true;
    }
1349942
private function checkGroupJoin() {
        $query = $this->getQueryObject();
        $params = $query->getQueryPart('join');
        $isGroupSet = false;
        $isUserGroupSet = false;
        // Loop twice as params returns an array of arrays
        foreach ($params as $param) {
            foreach ($param as $setTable)
                if (in_array('ug', $setTable)) {
                    $isUserGroupSet = true;
                }
            if (in_array('g', $setTable)) {
                $isGroupSet = true;
            }
        }
        if ($isUserGroupSet === false) {
            $query->leftJoin('u', 'UserGroups', 'ug', 'ug.uID = u.uID');
        }
        if ($isGroupSet === false) {
            $query->leftJoin('ug', $query->getConnection()->getDatabasePlatform()->quoteSingleIdentifier('Groups'),'g', 'ug.gID = g.gID');
        }
    }
187185
private boolean selectACollection()
    {
        if (!cfm.comparator.hasCollections())
            return false;

        for (ColumnDefinition def : selection.getColumns())
        {
            if (def.type.isCollection() && def.type.isMultiCell())
                return true;
        }

        return false;
    }
570569
public function selectAll() {
        // Build Select Command
        $sql_query = 'SELECT ' . $this->_distinct .
                     '* FROM ' . $this->_table;

        if (count($this->_joins)) {
            $sql_query .= implode($this->_joins, ' ');
        }
        
        // Where statements
        if (count($this->_where)) {
            $sql_query .= ' WHERE ';
            $sql_query .= implode($this->_where, ' AND ');
            
            // or statements
            if (count($this->_or)) {
                $sql_query .= ' OR ';
                $sql_query .= implode($this->_or, ' AND ');
            }
        }
        
        // Alias
        if ($this->_alias) {
            $sql_query .= ' AS ' . $this->_alias;
        }
        
        // Union
        if (count($this->_union)) {
            $sql_query .= ' UNION ' . implode($this->_union, ' UNION ');
        }
        
        // Union All
        if (count($this->_union_all)) {
            $sql_query .= ' UNION ALL ' . implode($this->_union_all, ' UNION ALL ');
        }
        
        // Group By
        if (strlen($this->_group_by)) {
            $sql_query .= $this->_group_by;
        }
        
        // Order By
        if (strlen($this->_order)) {
            $sql_query .= $this->_order;
        }
        
        // Limit
        if (strlen($this->_limit)) {
            $sql_query .= $this->_limit;
        }
        
        // Set the query
        $this->_sql_query = $sql_query;
        
        return $this;
    }
966098
def does_row_exist(self, table: str, field: str, value: Any) -> bool:
        """"""
        sql = ("SELECT COUNT(*) FROM " + self.delimit(table) +
               " WHERE " + self.delimit(field) + "=?")
        row = self.fetchone(sql, value)
        return True if row[0] >= 1 else False
1068507
def isdisjoint(self, other):
        """"""
        return not bool(self.db.sinter([self.key, other.key]))
831530
function (sql) {
            if (this._joinedDataset) {
                return format(" %s FROM %s%s", this._sourceList(this.__opts.from[0]), this._sourceList(this.__opts.from), this._selectJoinSql());
            } else {
                return this._super(arguments);
            }
        }
937960
public function posts_join(
		/** @noinspection PhpUnusedParameterInspection */
		$join, $wp_query
	) {
		/** @var \wpdb $wpdb */
		global $wpdb;
		$table = $this->app->db->get_table( $this->get_related_table_name() );
		$join  .= " INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID ";

		return $join;
	}