How to write a query with the in operator in mySQL?

The string tree in the database (data type text) = "1", "2", "3"

$x = 1;

As a record?

$sql = mysql_query( 'SELECT tree FROM a WHERE $x IN ( tree )' );

Can be fix on a tree 1, 2, 3 ? How do you record?
June 3rd 19 at 19:39
1 answer
June 3rd 19 at 19:41
Solution
Two tables are needed.
First tbl_a with data about the tree. For example, with fields id, title:
id title
1 maple
2 oak

In the second tbl_b , put the enumerated values one at a time, with reference to the id of the tree to which it relates. There are fields id, a_id, x:
id a_id x
7 1 1
8 1 2
9 1 3

Now you can find General information of the tree, which has the value x=1:
SELECT tbl_a.* 
FROM tbl_a JOIN tbl_b ON tbl_a.id = tbl_b.a_id 
WHERE tbl_b.x = 1
Thank you. I.e. to expand a row in the column. I'll try. - tanner7 commented on June 3rd 19 at 19:44

Find more questions by tags MySQL