I have a table of this manner:
+---------+--------------------+
|ID | Component |
+---------+--------------------+
|00241147 | 000000001000245598 |
|00241147 | 000000001000090069 |
|00249207 | 000000002510256707 |
|00249208 | 000000002510245146 |
+---------+--------------------+
I want to select only those rows where Component is starting with '1'.
I'm using the following code:
select * from Table where Component like '%1%'
Cast them as bigint and read 1 using left() function
select * from Table where left(cast(Component as bigint), 1) = 1
Note : This above assumes that Component column has varchar datatype
EDIT : Thanks for making demo for clarification by Uwe Keim
http://sqlfiddle.com/#!6/1987d/4
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