Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to select values that start with symbols

Tags:

sql

php

mysql

I have category ( title ) start with alphabetical A

$sql = "select * from category_data WHERE category LIKE 'A%'";

And is working, but how I can select from database the category ( title ) which don't start with [A-Z] or [1-9] just with symbols

like image 833
Matei Zoc Avatar asked Oct 13 '15 09:10

Matei Zoc


People also ask

What is the role of the * symbol in a select statement?

If we want to return all columns of the table, we can use a (*) asterisk sign instead of writing whole columns of the table. Through the following query, we can return all columns of the table.

How do I select a specific row in SQL?

To select rows using selection symbols for character or graphic data, use the LIKE keyword in a WHERE clause, and the underscore and percent sign as selection symbols. You can create multiple row conditions, and use the AND, OR, or IN keywords to connect the conditions.


1 Answers

SELECT * FROM category_data WHERE ASCII(UPPER(LEFT(category,1))) IN(...)

You can pass allowed ASCII characters in your IN clause.

If you want to skip specific range, you can use NOT BETWEEN x AND y;

like image 61
Kristian Vitozev Avatar answered Nov 04 '22 02:11

Kristian Vitozev