i have these two queries, that i want to join together, but am not skilled enough to do it.
can anyone help me ?
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
SELECT cids,tp FROM searches_done where (keyword='keyword' and city='city' and page='page' and ipp='ipp') LIMIT 1
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 tp
from the first query to each result
SELECT c.*,s.tp FROM companies c WHERE c.id in (cids)
currently, it works since i run two queries ( by code ), and use the results i get from the first query in the second query.
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 )
i am now working on creating a new table that will contains sd_id, c_id
to normalize the database :\