As far as I know I can do something like:
"SELECT *
FROM my_table
WHERE my_field LIKE '0%'
OR my_field LIKE '1%'
OR my_field LIKE '2%' ";
Is there a way to achieve this with a regular expression or something like this:
"SELECT *
FROM my_table
WHERE my_field LIKE [only first char is 0-9]"??
EDIT: The field is not numeric and it can be something like "1 People", "211 Pies" and so on.
ROW_NUMBER (Window Function) ROW_NUMBER (Window Function) is a standard way of selecting the nth row of a table. It is supported by all the major databases like MySQL, SQL Server, Oracle, PostgreSQL, SQLite, etc.
Here's one way: SELECT *, IFNULL( ( SELECT col1 FROM table1 WHERE col1 IN ('012311','0123631','091233','092111') ), 'some_value' ) AS my_col1 FROM table1; Not neccessarily copy+paste, you will have to adjust for your specific case.
Try this
SELECT *
FROM BadlyDesignedTable
WHERE AnswerColumn RLIKE '^[0-9]+'
I was wondering if it was even possible to regex in where, found it on google in 30 seconds.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With