Re: How to get a part of field in select qurey?
Andrzej Kubaczyk schreef:
> Hello.
>
> In the table I have one column where I storage some data in format:
> Ac01,bc32,45sw
> Field contains a few part of data coma separated.
>
> +----------------+
> | types |
> +----------------+
> | Ac01,bc32,45sw |
> | df22,Ac45 |
> | dd22 |
> | we23,rd34,Ac33 |
> +----------------+
>
> I need to get a part of the field, for example data pass to pattern Ac
> %
>
> Demand result is:
> Aco1
> Ac45
> Ac33
>
> Do somebody knows how to do it using mysql function?
mysql> select nr, types, mid(types,locate('Ac',types),4) from actypes
where types like '%Ac%';
+----+----------------+---------------------------------+
| nr | types | mid(types,locate('Ac',types),4) |
+----+----------------+---------------------------------+
| 1 | AC01,bc32,45sw | AC01 |
| 4 | df22,Ac35 | Ac35 |
| 5 | we23,rd34,Ac33 | Ac33 |
+----+----------------+---------------------------------+
3 rows in set (0.00 sec)
--
Luuk
|