Okay. I have a whole list of products. Some are the same thing ie: same titles
I have a form where people search for the products. I organize the products by a rank I give each product when they are first created. I want to group up the products. For example if someone searches for Mac Book Air I want all of the Mac Book air Products To Show Up First even if mac book air case ranks higher than most mac book airs, I still want all of the Mac Book Airs grouped together first. How can I do this with mysql. Order By or Group By, etc...

Recommended Answers

All 2 Replies

Can you post your mysql tables in

? i will have a look if you do :)

You have to order the result set by an inline function like this:

select id, title from product 
order by concat(if(title like "%$user_input%", '000',''), title );

This will precede the title field used for sorting with a literal '000' if the search string (here named $user_input) is part of the title.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.