spiceydog Posted August 11, 2008 Share Posted August 11, 2008 I have a query that basically says "WHERE something LIKE %something% or somethingelse LIKE %something%" but I want it to sort by the field name so like all rows where something LIKE %something% is in front of somethingelse LIKE %something% results. Is there anyway of doing this WITHOUT unions? if not.. I really am confused by unions. could someone show me an example? Link to comment https://forums.phpfreaks.com/topic/119232-solved-sorting-your-mysql_query-by-field-names/ Share on other sites More sharing options...
fenway Posted August 12, 2008 Share Posted August 12, 2008 You can order by as many fields as you'd like.... Link to comment https://forums.phpfreaks.com/topic/119232-solved-sorting-your-mysql_query-by-field-names/#findComment-614842 Share on other sites More sharing options...
spiceydog Posted August 13, 2008 Author Share Posted August 13, 2008 you can order alphabetically and such... what I want is all results where something = $search to be first in the search results list BEFORE the results where somethingelse = $search. i dont know how else to put it... "ORDER BY something, somethingelse" will not work for this. Link to comment https://forums.phpfreaks.com/topic/119232-solved-sorting-your-mysql_query-by-field-names/#findComment-615292 Share on other sites More sharing options...
bluejay002 Posted August 13, 2008 Share Posted August 13, 2008 can you be more descriptive with that something and somethingelse? say, can you give the table structure, the fields you want to get, what field to search and how to sort it. Link to comment https://forums.phpfreaks.com/topic/119232-solved-sorting-your-mysql_query-by-field-names/#findComment-615300 Share on other sites More sharing options...
fenway Posted August 13, 2008 Share Posted August 13, 2008 you can order alphabetically and such... what I want is all results where something = $search to be first in the search results list BEFORE the results where somethingelse = $search. i dont know how else to put it... "ORDER BY something, somethingelse" will not work for this. If you're talking about weighting your search results, you'll have to design this. Link to comment https://forums.phpfreaks.com/topic/119232-solved-sorting-your-mysql_query-by-field-names/#findComment-616085 Share on other sites More sharing options...
spiceydog Posted August 14, 2008 Author Share Posted August 14, 2008 mhmm.. fixed it all.. just use UNIONs... works great.. Link to comment https://forums.phpfreaks.com/topic/119232-solved-sorting-your-mysql_query-by-field-names/#findComment-616237 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.