How to select multiple value column where they are common on specified field?

I have a table named myindex.

SELECT * FROM index WHERE term in ("A","B")

But I want just highlighted rows. this is my dictionary table. when user enter more than one keyword it should return its corresponding result. for example when user search "PHP Array" it should select all "PHP" term and also All "Array" terms that they have same doc_id.


  • In your query you say you want to select all rows wich contain an A or a B.

    Whats the reason you want those 2 rows? is it because doc_id = 4? in that case you need to do:

    SELECT * FROM `index` WHERE term in ("A","B") AND `doc_id` = 4