Finding a Specific Character in SQL Statement

LunchBox

Is there a way I can find a certain character using LIKE keyword?

For example, let's say I have the following values in COL1:

1.75
5.50
5.67

I want to write a SQL statement that only returns values from COL1 where the second character AFTER the decimal is a zero (regardless of what the rest of the number says.)

Lukasz Szozda

Each value goes in this format: "#.##"

Then you could use wildcards % and _:

  • an underscore _ in pattern stands for (matches) any single character;
  • a percent sign % matches any sequence of zero or more characters.

Query:

SELECT * 
FROM tab 
WHERE col1 LIKE '%._0%';

SqlFiddleDemo

Output:

╔══════╗
║ col1 ║
╠══════╣
║ 5.50 ║
╚══════╝

If values are only numbers (with two places only) you could use simple modulo division:

SELECT *
FROM tab 
WHERE col1 % 0.1 = 0;

SqlFiddleDemo2

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Finding a Specific Character and/or String SQL Server 2008

From Dev

Finding the "&" character in SQL SERVER using a like statement and Wildcards

From Dev

Finding ranges of specific character in a string

From Dev

Finding Non Matches in SQL Statement

From Dev

If statement for directory starting with specific character

From Dev

Finding the last specific character type in a string

From Dev

Finding string between 2 specific character

From Dev

Finding the index of a character to match in a specific regex

From Dev

Finding filenames that end in a specific character with or without an extension

From Dev

Finding the most specific record - SQL

From Dev

Specific character in sql

From Dev

Finding a ruby hash value in an SQL statement search

From Dev

Finding the first occurrence of a given/ specific character inside every word

From Dev

If statement is 1 then run specific SQL statement

From Dev

Get part of a string in a sql statement based on a character

From Dev

SQL Server: Replace Arabic Character in Select Statement

From Dev

Need help finding many float value errors in a large SQL statement

From Dev

SQL: replace specific character from string

From Dev

Replacing a specific Unicode Character in MS SQL Server

From Dev

Split string at specific character SQL-Standard

From Dev

SQL Server : select all after specific character

From Dev

Append a specific character after each character of a string in sql server

From Dev

Remove first and last character if has specific character in SQL Server?

From Dev

Restricting WHERE clause to specific SELECT statement in sql

From Dev

Getting a specific timezone in rails sql statement

From Dev

Simple SQL statement to retrieve orders on a specific date

From Dev

sql statement does not work on specific table

From Dev

Simple SQL statement to retrieve orders on a specific date

From Dev

Selecting a specific date with a PL/SQL statement

Related Related

  1. 1

    Finding a Specific Character and/or String SQL Server 2008

  2. 2

    Finding the "&" character in SQL SERVER using a like statement and Wildcards

  3. 3

    Finding ranges of specific character in a string

  4. 4

    Finding Non Matches in SQL Statement

  5. 5

    If statement for directory starting with specific character

  6. 6

    Finding the last specific character type in a string

  7. 7

    Finding string between 2 specific character

  8. 8

    Finding the index of a character to match in a specific regex

  9. 9

    Finding filenames that end in a specific character with or without an extension

  10. 10

    Finding the most specific record - SQL

  11. 11

    Specific character in sql

  12. 12

    Finding a ruby hash value in an SQL statement search

  13. 13

    Finding the first occurrence of a given/ specific character inside every word

  14. 14

    If statement is 1 then run specific SQL statement

  15. 15

    Get part of a string in a sql statement based on a character

  16. 16

    SQL Server: Replace Arabic Character in Select Statement

  17. 17

    Need help finding many float value errors in a large SQL statement

  18. 18

    SQL: replace specific character from string

  19. 19

    Replacing a specific Unicode Character in MS SQL Server

  20. 20

    Split string at specific character SQL-Standard

  21. 21

    SQL Server : select all after specific character

  22. 22

    Append a specific character after each character of a string in sql server

  23. 23

    Remove first and last character if has specific character in SQL Server?

  24. 24

    Restricting WHERE clause to specific SELECT statement in sql

  25. 25

    Getting a specific timezone in rails sql statement

  26. 26

    Simple SQL statement to retrieve orders on a specific date

  27. 27

    sql statement does not work on specific table

  28. 28

    Simple SQL statement to retrieve orders on a specific date

  29. 29

    Selecting a specific date with a PL/SQL statement

HotTag

Archive