How to find rows that have a value that contains a lowercase letter

前端 未结 13 1416
醉梦人生
醉梦人生 2021-02-01 00:36

I\'m looking for an SQL query that gives me all rows where ColumnX contains any lowercase letter (e.g. \"1234aaaa5789\"). Same for uppercase.

相关标签:
13条回答
  • 2021-02-01 00:55
    mysql> SELECT '1234aaaa578' REGEXP '^[a-z]';
    
    0 讨论(0)
  • 2021-02-01 00:56

    for search all rows in lowercase

    SELECT *
    FROM Test
    WHERE col1 
    LIKE '%[abcdefghijklmnopqrstuvwxyz]%'
    collate Latin1_General_CS_AS
    

    Thanks Manesh Joseph

    0 讨论(0)
  • 2021-02-01 00:57

    I'm not an expert on MySQL I would suggest you look at REGEXP.

    SELECT * FROM MyTable WHERE ColumnX REGEXP '^[a-z]';
    
    0 讨论(0)
  • 2021-02-01 00:58

    IN MS SQL server use the COLLATE clause.

    SELECT Column1
    FROM Table1
    WHERE Column1 COLLATE Latin1_General_CS_AS = 'casesearch'
    

    Adding COLLATE Latin1_General_CS_AS makes the search case sensitive.

    Default Collation of the SQL Server installation SQL_Latin1_General_CP1_CI_AS is not case sensitive.

    To change the collation of the any column for any table permanently run following query.

    ALTER TABLE Table1
    ALTER COLUMN Column1 VARCHAR(20)
    COLLATE Latin1_General_CS_AS
    

    To know the collation of the column for any table run following Stored Procedure.

    EXEC sp_help DatabaseName
    

    Source : SQL SERVER – Collate – Case Sensitive SQL Query Search

    0 讨论(0)
  • 2021-02-01 01:01

    In Posgresql you could use ~

    For example you could search for all rows that have col_a with any letter in lowercase

    select * from your_table where col_a '[a-z]';

    You could modify the Regex expression according your needs.

    Regards,

    0 讨论(0)
  • 2021-02-01 01:01

    --For Sql

    SELECT *
    FROM tablename
    WHERE tablecolumnname LIKE '%[a-z]%';
    
    0 讨论(0)
提交回复
热议问题