精华内容
下载资源
问答
  • 数据库中desc和asc

    千次阅读 2019-01-14 21:44:22
    desc:将表的数据按照某列进行降序排列  例 name age salary 独孤九剑 66 11000 李莫愁 45 12030 萧十一郎 35 10240 乔峰 40 15230    select * from table order ...

    desc:将表中的数据按照某列进行降序排列

          例

    name age salary
    独孤九剑 66 11000
    李莫愁 45 12030
    萧十一郎 35 10240
    乔峰 40 15230

     

       select * from table order by salary desc   排序后的表如下:

           

    name age salary
    乔峰 40 15230
    李莫愁 45 12030
    独孤九剑 66 11000
    萧十一郎 35 10240

    asc:将表中的数据进行升序排序

     默认情况下为asc

    展开全文
  • 数据库是保存表和其他相关sql结构的...同一个数据库中的表可以有关系也可以没有关系,但是最好有关系,不然,放在同一个数据库中做什么。 这样,相互之间有关系的表组成了 ---------- 关系型数据库   mysql 指令:

    数据库是保存表和其他相关sql结构的容器
    数据库由表组成,表示在数据库中包含数据的结构,由列和行组成
    表的列(字段)----定义了存储数据的类型
    表的行(记录)---- 包含了表中某个对象的所有信息

    同一个数据库中的表可以有关系也可以没有关系,但是最好有关系,不然,放在同一个数据库中做什么。
    这样,相互之间有关系的表组成了 ----------  关系型数据库

     

    mysql 指令:
    1、创建一个数据库
    create database greps_list;
    2、使用该数据库
    use greps_list;
    3、创建一个表:
    create table doughnut_list
    {
       doughnut_name VARCHAR(10),
       doughnut_type  VARCHAR(6)
    };

    VARCHAR--- variable character(可变动字符)  数字10 表示这段文字的长度最多只能10个


    4、描写(作图)表
    desc doughnut_list;

    desc  ----describe

    5、把数据添加进表中 ------- insert
    insert into your_table (column_name1,column_name2,...) values ('value1','value2',...);


    5、删除表
    drop table  doughnut_list;

    展开全文
  • 在数据库设计完成之后, 常常需要在 wiki 或其他文档中保存一份数据库中所有表的 desc 描述, 尤其是每个字段的含义和用途。 手动去生成自然是不可取的。 因此, 我编写了一个简单的 python 程序,可以自动生成...

     

           在数据库设计完成之后, 常常需要在 wiki 或其他文档中保存一份数据库中所有表的 desc 描述, 尤其是每个字段的含义和用途。 手动去生成自然是不可取的。 因此, 我编写了一个简单的 python 程序,可以自动生成数据库中所有表的 desc 描述, 并以可读格式输出。

           

    # -*- coding: utf-8 -*-
    # -------------------------------------------------------------------------------
    # Name:          db_tables_descs.py
    # Purpose:       generate the tables that describe the meanings of fields in db
    #
    # Author:       qin.shuq
    #
    # Created:      2014/11/17
    # Output:       desc.txt
    #               recording the tables that describe the meanings of fields in db
    #-------------------------------------------------------------------------------
    #!/usr/bin/env python
    
    import db
    
    globalFieldDescs = ('Field', 'Type', 'Null', 'Key', 'Default', 'Extra')
    
    globalDescFile = 'desc.txt'
    
    conflictedWithMysqlKeywords = set(['group'])
    
    fieldDescMapping = {
        'id':         '唯一标识',
        'is_deleted': '是否逻辑删除',
        'status':     '实体状态',
        'type':       '实体类型',
        'priority':   '优先级',
        'password':   '密码',
        'ip':         'ip 地址',
        'mac':        'mac 地址',
        'protocol':   '访问协议',
        'user_id':    '用户唯一标识'
    }
    
    def formatCols(fieldDesc):
        return  "%-16s %-24s %-5s %-8s %-8s %-30s" % fieldDesc
    
    def withNewLine(astr):
        return astr + '\n'
    
    
    def commonFieldsProcess(fieldDescList):
        fieldName = fieldDescList[0]
        fieldDesc = fieldDescMapping.get(fieldName)
        desclen =   len(fieldDescList)
        if fieldDesc is None:
            if fieldName.startswith('gmt_c'):
                fieldDesc = '创建时间'
            elif fieldName.startswith('gmt_m'):
                fieldDesc = '修改时间'
            else:
                fieldDesc = fieldDescList[desclen-1]
        fieldDescList[desclen-1] = fieldDesc
    
    def formatF(fieldDescTuple):
        fieldDescList = list(fieldDescTuple)
        fieldLen = len(fieldDescList)
        for i in range(fieldLen):
            if fieldDescList[i] is None:
                fieldDescList[i] = 'NULL'
            else:
                fieldDescList[i] = str(fieldDescList[i])
        commonFieldsProcess(fieldDescList)
        return formatCols(tuple(fieldDescList))
    
    def format(tableDesc):
        desc = ''
        for fieldDescTuple in tableDesc:
            desc += withNewLine(formatF(fieldDescTuple))
        return desc
    
    def descDb(givenDb):
        tablesRet = givenDb.query("show tables;")
        tableNames = [table[0] for table in tablesRet]
        desc = u''
        for tablename in tableNames:
            if tablename in conflictedWithMysqlKeywords:
                tablename = '`' + tablename + '`'
            descSql = "desc " + tablename
            tableDesc = givenDb.query(descSql)
            desc += withNewLine(tablename)
            desc += withNewLine(formatCols(globalFieldDescs)).decode('utf-8')
            desc += withNewLine(format(tableDesc)).decode('utf-8')
            desc += withNewLine('').decode('utf-8')
        return desc
    
    
    def main():
    
        descFile = open(globalDescFile, 'w')
    
        desc = descDb(db.Mydb())
        descFile.write(desc.encode('utf-8'))
    
        descFile.close()
    
    
    if __name__ == '__main__':
        main()

    db.py

    #!/usr/ali/bin/python
    # coding=utf-8
    
    '''Implements a database api to your db.
    
    Example 1: Query SQL
    
    a. Use execute() method to execute query sql:
    
        db.execute('select * from ip')
    
        # Get only the first two rows
        db.get_rows(2)
        # result like [('10.10.0.1', 'my'), ..]
    
        # Get the next two rows, but each row record is a dict
        db.get_rows(2, is_dict = True)
        # result like [{'address':'10.10.0.1', 'name': 'my'}, ..]
    
    b. Use query() method to execute query sql directly:
    
        # The query() method will get the result rows immediately
        db.query('select * from ip', size = 2, is_dict = True)
    
    c. Use split_query() method to split long query into small ones:
    
       # Assume that the name_list's length is 10000
       # See the docstring of split_query() for more details
       db.split_query('select address from ip', 'name', name_list)
    
    Example 2: Insert SQL
    
    a. Insert a new record into ip table:
    
        db.execute("insert into ip('address','name') values('192.168.0.1','vm-xxx')")
    
        # If auto commit set to false, call commit() method manually
        db.commit()
    
    b. Insert multi-records into ip table:
    
        db.executemany("insert into ip('address','name') values(%s,%s)", [
                ('192.168.0.1', 'vm-xxx'),
                ('192.168.0.2', 'vm-yyy'),
                ('192.168.0.3', 'vm-zzz')])
        db.commit()
    
    Note: db.multi_insert is an alias for executemany method.
    See test_main() method for more examples.
    '''
    
    from database import DB
    
    class Mydb(DB):
        '''A simple query interface of a specific database.'''
        def __init__(self, read_only = True,
                     auto_commit = False, timeout = 5, auto_connect = False,
                     max_idle_time = 28800):
            '''Initialize the database access object.'''
            # Get the database parameters
            args = {'host':'127.0.0.1', 'user':'root','passwd':'123456','db':'mysql','port':3306,'charset':'utf8'}
    
            # Set extra connection parameters
            args['connect_timeout'] = timeout
            args['auto_commit'] = auto_commit
            args['max_idle_time'] = max_idle_time
            args['auto_connect'] = auto_connect
    
            DB.__init__(self, **args)

    database.py

    #!/usr/ali/bin/python
    # coding=utf-8
    
    '''Implements a simple database interface
    
    Example 0: Create connection:
    
        # Set auto commit to false, default case
        db = DB(auto_commit = False, host = 'x', user = 'x', passwd = 'x', db = 'x')
        # Set auto commit to true
        db = DB(auto_commit = True, host = 'x', user = 'x', passwd = 'x', db = 'x')
        # Set auto connect to true, this will set auto commit to true too
        # This will enable auto connect when the connection is timeout
        db = DB(auto_connect = True, host = 'x', user = 'x', passwd = 'x', db = 'x')
    
    Example 1: Query SQL
    
    a. Use query() method to execute query sql directly:
    
        # The query() method will get the result rows immediately
        db.query('select * from ip', size = 2, is_dict = True)
    
    c. Use split_query() method to split long query into small ones:
    
       # Assume that the name_list's length is 10000
       # See the docstring of split_query() for more details
       db.split_query('select address from ip', 'name', name_list)
    
    Example 2: Insert SQL
    
    a. Insert a new record into ip table:
    
        db.execute("insert into ip('address','name') values('192.168.0.1','vm-xxx')")
    
        # If auto commit set to false, call commit() method manually
        db.commit()
    
    b. Insert multi-records into ip table:
    
        db.executemany("insert into ip('address','name') values(%s,%s)", [
                ('192.168.0.1', 'vm-xxx'),
                ('192.168.0.2', 'vm-yyy'),
                ('192.168.0.3', 'vm-zzz')])
        db.commit()
    
    Note: db.multi_insert is an alias for executemany method.
    '''
    
    # Can be 'Prototype', 'Development', 'Product'
    __status__ = 'Development'
    __author__ = 'tuantuan.lv <tuantuan.lv@alibaba-inc.com>'
    
    import re
    import time
    import MySQLdb
    
    from storage import Storage
    
    OperationalError = MySQLdb.OperationalError
    
    def _format(sql):
        '''Format the sql.'''
        return ' '.join(sql.split())
    
    class DB():
        '''A simple database query interface.'''
        def __init__(self, auto_commit = False, auto_connect = False,
                     max_idle_time = 28800, **kwargs):
            '''Initialize the DB object.'''
            #
            # Remember the max idle time (default: 28800)
            # You should set this value to mysql option 'wait_timeout'
            #
            # mysql> show variables like 'wait_timeout';
            # +---------------+-------+
            # | Variable_name | Value |
            # +---------------+-------+
            # | wait_timeout  | 28800 |
            # +---------------+-------+
            #
            self.max_idle_time = max_idle_time
    
            kwargs.setdefault('charset', 'utf8')             # set default charset to utf8
            kwargs['port'] = int(kwargs.get('port', '3306')) # set default port to 3306
    
            self._db = None                     # MySQLdb connection object
            self._db_cursor = None              # MySQLdb cursor object
            self.cursor = None                  # MySQLdb cursor object, deprecated
            self._db_args = kwargs              # MySQL db connection args
            self._last_use_time = time.time()   # Last active time
    
            self._auto_connect = auto_connect   # Auto connect when timeout
            self._auto_commit = auto_commit     # Auto commit
    
            # Open a new mysql connection
            self._reconnect()
    
        def __del__(self):
            self.close()
    
        def close(self):
            '''Close the database connection.'''
            if self._db is not None:
                self._db_cursor.close()
                self._db.close()
                self._db = None
    
        def _reconnect(self):
            '''Close existing connection and re-open a new one.'''
            self.close()
            self._db = MySQLdb.connect(**self._db_args)
    
            # Override auto commit setting if auto connect is true
            if self._auto_connect:
                self._db.autocommit(True)
            else:
                self._db.autocommit(self._auto_commit)
    
            self._db_cursor = self._db.cursor()
            self.cursor = self._db_cursor
    
        def _ensure_connected(self):
            '''Ensure we connect to mysql.'''
            # Mysql by default closes client connections that are idle for
            # 8 hours, but the client library does not report this fact until
            # you try to perform a query and it fails.  Protect against this
            # case by preemptively closing and reopening the connection
            # if it has been idle for too long (8 hours by default).
            if (self._db is None or
                (time.time() - self._last_use_time > self.max_idle_time)):
                self._reconnect()
    
            self._last_use_time = time.time()
    
        def _cursor(self):
            '''Get the cursor.'''
            if self._auto_connect:
                self._ensure_connected()
    
            return self._db_cursor
    
        def execute(self, sql, args = None):
            '''Execute a sql and return the affected row number.
    
            You should call the get_rows method to fetch the rows manually.
            '''
            cursor = self._cursor()
            return cursor.execute(_format(sql), args)
    
        def execute_lastrowid(self, sql, args = None):
            '''Execute a sql and return the last row id.
    
            You should call the get_rows method to fetch the rows manually.
            '''
            cursor = self._cursor()
            cursor.execute(_format(sql), args)
    
            return cursor.lastrowid
    
        def executemany(self, sql, args):
            '''Execute a multi-row insert.
    
            You can use this method to do a multi-row insert:
    
               c.executemany(
                  """INSERT INTO breakfast (name, spam, eggs, sausage, price)
                  VALUES (%s, %s, %s, %s, %s)""",
                  [
                  ("Spam and Sausage Lover's Plate", 5, 1, 8, 7.95 ),
                  ("Not So Much Spam Plate", 3, 2, 0, 3.95 ),
                  ("Don't Wany ANY SPAM! Plate", 0, 4, 3, 5.95 )
                  ] )
    
            See http://mysql-python.sourceforge.net/MySQLdb.html for more help.
            '''
            cursor = self._cursor()
            return cursor.executemany(_format(sql), args)
    
        # Execute a multi-row insert, the same as executemany()
        multi_insert = executemany
    
        def get_rows(self, size = None, is_dict = False):
            '''Get the result rows after executing.'''
            cursor = self._cursor()
            description = cursor.description
    
            if size is None:
                rows = cursor.fetchall()
            else:
                rows = cursor.fetchmany(size)
    
            if rows is None:
                rows = []
    
            if is_dict:
                dict_rows = []
                dict_keys = [ r[0] for r in description ]
    
                for row in rows:
                    dict_rows.append(Storage(zip(dict_keys, row)))
    
                rows = dict_rows
    
            return list(rows)
    
        def query(self, sql, args = None, size = None, is_dict = False):
            '''Execute a query sql and return the rows immediately.'''
            self.execute(sql, args)
            return self.get_rows(size, is_dict)
    
        # Alias of query() method
        select = query
    
        def split_query(self, sql, in_attr, in_list, max_cnt = 3000):
            '''Split one long query into many small ones.
    
            For example, if you want to select the records whose attrname is in
            one long list (larger than 8000) of possible values. If you decide to
            use 'attr in (...)' syntax, the length will exceed the maximum length
            of one sql allowed. In this case you must split the long query into many
            small ones.
    
            in_attr is the attribute name of in operator, and in_list is the possible
            value list. max_cnt is the maximum count of values in one small query.
            '''
            total = len(in_list)
    
            start = 0
            end = max_cnt
    
            result = []
    
            if re.search(r'\bwhere\b', sql.lower()):
            #if sql.lower().find('where ') != -1 or sql.lower().find('where\n') != -1:
                sql = '%s and %s in %%s' % (sql, in_attr)
            else:
                sql = '%s where %s in %%s' % (sql, in_attr)
    
            while start < total:
                if end < total:
                    in_expr = "('%s')" % "','".join(in_list[start:end])
                else:
                    in_expr = "('%s')" % "','".join(in_list[start:])
    
                result.extend(self.query(sql % in_expr))
    
                start = end
                end += max_cnt
    
            return result
    
        #def get_autoincrement_id(self, tbl):
        #    '''Get the next auto increment id of table.
        #
        #    Return None if the table doesn't have an auto-increment id.
        #    '''
        #    self.execute('SHOW TABLE STATUS LIKE %s', (tbl,))
        #    result = self.get_rows(is_dict = True)
    
        #    if result[0]:
        #        return result[0]['Auto_increment']
        #    else:
        #        return None
    
        def commit(self):
            '''Commits the current transaction.'''
            if self._db is not None:
                self._db.commit()
    
        def rollback(self):
            '''Rollback the last transaction.'''
            if self._db is not None:
                self._db.rollback()
    
    # vim: set expandtab smarttab shiftwidth=4 tabstop=4:

    storage.py

    #!/usr/ali/bin/python
    # coding=utf-8
    
    '''Wrap an existing dict, or create a new one, and access with dot notation
    
    See test_main() for more example.
    '''
    
    # Can be 'Prototype', 'Development', 'Product'
    __status__ = 'Development'
    __author__ = 'tuantuan.lv <tuantuan.lv@alibaba-inc.com>'
    
    # Taken from http://stackoverflow.com/a/12187277
    class Storage(object):
        '''Wrap an existing dict, or create a new one, and access with dot notation.
    
        The attribute _data is reserved and stores the underlying dictionary.
    
        args:
            d: Existing dict to wrap, an empty dict created by default.
            create: Create an empty, nested dict instead of raising a KeyError.
        '''
        def __init__(self, d = None, create = True):
            '''Initialize storage object.'''
            if d is None: # Create empty storage object
                d = {}
            else: # create as a dictionary?
                d = dict(d)
    
            # Set storage attributes
            self.__dict__['__storage_data'] = d
            self.__dict__['__storage_create'] = create
    
        def __getattr__(self, name):
            '''Get the key value.'''
            try:
                value = self.__dict__['__storage_data'][name]
    
            except KeyError:
                # Create empty storage value if auto-create set to true
                if not self.__dict__['__storage_create']:
                    raise
    
                value = {}
                self.__dict__['__storage_data'][name] = value
    
            # Create nested dict if the value has items attribute
            if isinstance(value, dict):
                value = Storage(value, self.__dict__['__storage_create'])
                self.__dict__['__storage_data'][name] = value
    
            return value
    
        def __setattr__(self, name, value):
            '''Set the storage key to value'''
            self.__dict__['__storage_data'][name] = value
    
        def __delattr__(self, name):
            '''Delete the storage key.'''
            del self.__dict__['__storage_data'][name]
    
        def __contains__(self, name):
            '''Check whether the key exists.'''
            return name in self.__dict__['__storage_data']
    
        def __nonzero__(self):
            '''Check whether the storage is empty.'''
            return bool(self.__dict__['__storage_data'])
    
        # Defines common dict api
        __getitem__ = __getattr__
        __setitem__ = __setattr__
        __delitem__ = __delattr__
    
        def get(self, name, default = None):
            '''Defines an get method.'''
            return self.__dict__['__storage_data'].get(name, default)
    
        # Define dictionary like methods
        def keys(self):
            return self.__dict__['__storage_data'].keys()
    
        def items(self):
            return self.__dict__['__storage_data'].items()
    
        def values(self):
            return self.__dict__['__storage_data'].values()
    
        def setdefault(self, name, default = None):
            return self.__dict__['__storage_data'].setdefault(name, default)
    
        def pop(self, name, *args):
            return self.__dict__['__storage_data'].pop(name, *args)
    
        def update(self, d, **kwargs):
            return self.__dict__['__storage_data'].update(d, **kwargs)
    
        def clear(self):
            self.__dict__['__storage_data'].clear()
    
        def __len__(self):
            return len(self.__dict__['__storage_data'])
    
        def __iter__(self):
            return self.__dict__['__storage_data'].__iter__()
    
        def __unicode__(self):
            return u'<Storage %s>' % str(self.__dict__['__storage_data'])
    
        def __str__(self):
            return '<Storage %s>' % str(self.__dict__['__storage_data'])
    
        def __repr__(self):
            return '<Storage %s>' % repr(self.__dict__['__storage_data'])
    
    def test_main():
        # Create an empty storage
        d1 = Storage()
        d1.a.b = 1
        d1.b.c = 2
    
        # Iterate the items in storage object
        for k, v in d1.items():
           print k, v
    
        # Create a storage in a (key,value) tuple
        d3 = Storage(zip(['a','b','c'], [1,2,3]))
        print d3.a, d3.b, d3.c
        print d3
    
        # Create a storage from a existing dict
        d4 = Storage({'a':{'b':1}})
        print d4.a.b
        print d4
    
        # Check the attribute
        d5 = Storage()
        print 'a' in d5 # False
        print d5.a      # create attribute 'a'
        print 'a' in d5 # True
        print d5.get('c')
        print d5.get('d', 3)
    
        d5 = Storage(create = False)
        print 'a' in d5 # False
        print d5.get('a', 5)
        print d5.a      # raise KeyError
        print 'a' in d5 # False, also
    
    if __name__ == '__main__':
        test_main()

     

    转载于:https://www.cnblogs.com/lovesqcc/p/4104359.html

    展开全文
  • asc是升序,就是这个值按照从小到大进行排序;...数据库中使用order by语句进行排序,其中升序用asc,降序用desc。 如: select * from t order by 列a asc 这是升序 select * from t order by 列a desc 这是降序 ...

    asc(ascend )是升序,就是这个值按照从小到大进行排序;desc(descend)是降序,就是这个值按照从大到小进行排序。

    你只要把这两个单词背会,就很容易记住他们的作用啦!

    数据库中使用order by语句进行排序,其中升序用asc,降序用desc。

    select * from table order by id desc  根据id字段按照降序排列,从大到小
    select * from table order by id asc  根据id字段按照升序排列,从小到大
    
    展开全文
  • 在sql server数据库取某一行数据 select top 3 * from table order by id desc 这是选择第三行 在 Mysql 数据库取某一行数据 select * from tongzhi order by id desc limit 1; 按照id的倒序排序 取第一条数据 ...
  • #EXPLAIN语句可以用作DESC(DESCRIBE)的一个同义词,以下效果相同 EXPLAIN book; DESC book; DESCRIBE book;
  • Sequelize数据库中文排序

    万次阅读 2020-10-22 09:36:34
    首先要排序的字段要是索引,然后一下是Sequelize的代码 ...order: [[ sequelize.literal(‘convert(name using gbk)’), ‘DESC’ ]] }); 按照name字段来进行排序,DESC表示逆序 const sequelize = this.ctx
  • 本人在开发程序中要的到Oracle数据库中某一条数据。如题。要得到第二条数据。本人在开发程序中要的到Oracle数据库中某一条数据。如题。要得到第二条数据。表明为:t_ltr_kjmx答案:select * from (select * from t_...
  • 数据库中的排序问题

    千次阅读 2018-03-26 09:59:09
    遇到了有null的情况,通过百度试了上面的方法都不行,后来发现数据库中的不是NULL,而是字符串“null”,后来将sql语句改成order by case when col = “null” then 1 else 0 end , col desc;为什么先1后0?因为...
  • MySql数据库中的权限授予 授予权限 需要使用实例级账户登录后操作,以root为例 主要操作包括: 查看所有用户 修改密码 删除用户 1. 查看所有用户 所有用户及权限信息存储在mysql数据库的user表中 查看user表的结构...
  • 我可以使用以下代码从数据库中获取所需的数据:$sql="SELECT * FROM `signals` order by `time` DESC LIMIT 100";$result = mysqli_query($DatabasePointer,$sql)or die(mysqli_error($Databa...
  • orale中的排序最基本的order by desc或asc大家应该都比较熟悉,那么其他的排序方式,比如中文的按拼音排序,按笔画排序,或者想自定义排序都有什么方法呢,下面介绍oracle数据库中排序的几种方式。 1.简单的升序、...
  • 数据库

    2020-10-31 22:07:44
    net stop mysql 停止数据库服务 net start mysql 开始数据库服务 create database; 创建数据库 show databases;...desc stu; 查看创建的表结构 insert into stu values(1,“内容”); 向表插入数据
  • 近日,我在做一个前端排序功能时发现我使用&lt;vlh:column&...解决办法:在查找数据库表时在你的sql语句加入字段 order by convert(column_name using gbk) [desc] 但是这样做带来的坏处是意味...
  • 数据库中修改goods表结构 修改goods表结构 目前我们已经把good表中的商品分类和品牌信息已经更改成了商品分类id和品牌id,接下来需要把 cate_name 和 brand_name 字段分别改成 cate_id和 brand_id 字段,类型都...
  • 今天早上卡了我很久的一个问题,数据库使用了关键字desc Mybatis就必须要把关键字用 包起来,此 不是引号,而是Tab键上面那个键。我一直使用的是单引号,结果卡了我一早上,记录一下 ...
  • 表结构的增删改查 ...1)查看该数据库中的所有表:show tables 2)查看表结构:desc 表名 (3)表创建时约束 1)主键约束:primary key 主键自增长 id int primary key auto_increment:表示id...
  • 查询mysql数据库中表的行数与大小

    千次阅读 2019-07-10 13:46:41
    查询数据库中所有表的行数 use information_schema; select table_name,table_rows from tables where TABLE_SCHEMA = '数据库名' order by table_rows desc; 查询数据库中所有表的大小 select TABLE_NAME, ...
  • 数据库中的Hashtags

    2014-10-24 22:00:21
    $results = mysqli_query($mysqli, "SELECT * FROM blogdata_comments WHERE comment_content LIKE '%#$text%' ORDER BY comment_id DESC"); echo"<a style='color:#0000FF;' href='hash.php?tag=$text'>$...
  • 各个数据库中TOP10记录的查询方法

    千次阅读 2016-07-12 17:47:57
    各个数据库中TOP10记录的查询方法  Oracle数据库:  select * from (select * from tab order by id desc) where rownum  MySQL数据库:  select * from tab order by id desc limit 0, 10;  (这里...
  • 这个系统可以连接mysql适配虚谷的数据库,可从数据库中根据配置文件进行数据的采集。 1. 如果要添加新的数据库只需要继承DbClient 写一个新的需要加入的客户端,重写的方法主要为了连接数据库,获取表的信息。 ...
  • div class="desc"> <strong> <a href="product.html">s</a> </strong> <span class="light-clr qty"> <a href="#" class="icon-remove-sign" title="Remove Item"><...
  • sql server数据库,去除数据库重复的数据 DELETE LU FROM (SELECT *, Row_number() OVER ( partition BY stcd ,reporttime ,tm ORDER BY tm DESC) [Row] FROM ST_PREAL) LU WHERE [row] > 1 ...
  • MySql查看数据库中所有表的创建时间

    千次阅读 2018-12-19 16:09:16
    MySql查看数据库中所有表的创建时间等信息: SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '数据库名' ORDER BY create_time DESC;
  • PHP 列出数据库中数据

    2017-01-01 19:22:22
    php列出数据库中数据 $row = $rows = array(); $sql=mysql_query("SELECT * FROM shouzhi ORDER BY shouzhi_time DESC"); $total = mysql_num_rows($sql); while($row = mysql_fetch_array($sql) ){ $rows[]=$row; }...
  • 查询最新插入数据库中的数据 MySql : SELECT * FROM 表名 ORDER BY 表_ID DESC LIMIT 1 SQLServer/Oracle : SELECT TOP 1 * FROM 表名 ORDER BY 表_ID DESC 转载于:...
  • SQLServer: select a.name as 表名, max(b.rows) as 记录条数 from sysobjects as a, sysindexes as b where a.id = b.id and a.xtype =...order by max(b.rows) desc; 或者 select a.name as 表名, b
  • 1. 先去数据库中查值,查询整个数据表,结果为二维数组。 $project = M(project); $cell = $project->where(array('status'=>1))->order(id desc)->select(); //var_dump($cell); $this->assign('cell',$cell);...
  • 传统的排序方法,比如select * from tableA order by id desc可以对英文、数字进行排序。但是遇到中文就没有办法了。这个时候需要以下的语句:  select * from tableAorder by convert(name using gbk) collate ...
  • 数据库中的分组排序

    千次阅读 2019-08-01 14:57:36
    row-number() over(partition by 分组列字段 order by 排序列字段 desc) row_number() over()分组排序功能: 在使用 row_number() over()函数时候,over()里头的分组以及排序的执行晚于 where 、group by、 ord...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 3,133
精华内容 1,253
关键字:

数据库中desc