title: Select rows from table where id is in a comma seperated list in another table
body: <p>i have these two queries, that i want to join together,
  but am not skilled enough to do it.</p>
  
  <p>can anyone help me ?</p>
  
  <p>this is selecting the row that matches the search
  which contains a column cids, that in turn i need to use in the second query</p>
  
  <p><code>SELECT cids,tp FROM searches_done where (keyword='keyword' and city='city' and page='page' and ipp='ipp') LIMIT 1</code></p>
  
  <p>this query selects the actual result rows, which comparing the id of each company to the column seperated values we got in the first query (cids)
  also, it needs to attached the column <code>tp</code> from the first query to each result</p>
  
  <p><code>SELECT c.*,s.tp FROM companies c WHERE c.id in (cids)</code></p>
  
  <p>currently, it works since i run two queries ( by code ),
  and use the results i get from the first query in the second query.</p>
  
  <pre><code>searches_done table structure:
  
  id - autoincrement unique int  
  keyword - varchar(255) - keyword that was searched
  page - int - paging page ( i.e: page=0 its the first page etc.. )
  city - varchar(255) - keyword for city that was searched 
  cids - text - comma seperated values of the companies ids 
                  ( that were found matching this search )   
  tp - int - total pages found
  ipp - int - itemsperpage ( a search could be done with only 10 items per page
                           , so diffrent results might be found with 10/100 )
  </code></pre>
  
  <p>i am now working on creating a new table that will contains <code>sd_id, c_id</code> to normalize the database :\</p>