I have the following 1,2,3 in a column called 'x' and I would like to select * where x = 1
How would I do this? do I need IN? I cant seem to get it to work..
Thanks!!
selecting from an array in mysql
Moderator: General Moderators
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- dibyendrah
- Forum Contributor
- Posts: 491
- Joined: Wed Oct 19, 2005 5:14 am
- Location: Nepal
- Contact:
Code: Select all
mysql> create database testdb;
Query OK, 1 row affected (0.05 sec)
mysql> use testdb;
Database changed
mysql> create table test (
-> x varchar(255)
-> );
Query OK, 0 rows affected (0.03 sec)
mysql> insert into test values('4,10');
Query OK, 1 row affected (0.00 sec)
mysql> insert into test values('5,10');
Query OK, 1 row affected (0.00 sec)
mysql> select * from test;
+------+
| x |
+------+
| 4,10 |
| 5,10 |
+------+
2 rows in set (0.00 sec)
mysql> select x from test where x like '%4%'
-> ;
+------+
| x |
+------+
| 4,10 |
+------+
1 row in set (0.00 sec)Dibyendra