Wednesday 15 September 2010

php - MySQL: Use search results (Like %search%), to match id's in another table in the database -


OK, there are so many things going on with me ...

Give me In the tables are the databases, parts and products, I have a column in the table of products, with the string of the ID table (separated by commas), which is the id ID of the ID table.

  ** Part ** ID | Description (I'm looking for this part) ------------------------------- 1 | Here are some lessons. Some different text here 3. Ect ... ** Products ** ID | Part-List -------------------------------- 1 | 1,2,3 2 2,3 3 1,2   

I'm really struggling with SQL query on this one I have divided 1, get the ID from the Part table

SELECT * FROM parts WHERE description LIKE '% {$ search}%'

The biggest problem is the separation structure of the comma column.

Obviously I can do this in PHP, create an array of results from the Parts table, use that to find the table of products for the ID, and then using those results, Again) to obtain row data from Not very efficient

I also tried it, but I am clearly trying to compare two arrays here, not sure how it should be done.

  SELECT * FROM 'product' where concrete (',', description, ',') IN (`` ``% {$ search}% '`` ` Select 'details')   

Can someone help?

Thank you.

I could probably location () and SUBSTR () . I mainly work in MSSQL which contains CHARINDEX () which I think works like MySQL's LOCATE () . It must be messy. Is there a variable number of elements in the part-list field?

No comments:

Post a Comment