gerkintrigg Posted July 16, 2012 Share Posted July 16, 2012 I seem to have a problem when outputting data from my site search. It used to work fine but it seems that I have a huge number of records in my database with the same information or (FAR more likely), I'm calling that data multiple times. Here's my code: $search_explode=$search; $my_search_explode=explode(' in ',$search); $biz_type=trim($my_search_explode[0],'s'); $town_to_search=$my_search_explode[1]; $q="SELECT `page_title`,`profile_name`,`page_id`,`content`,`active`,`small_logo`,`pages`.`member_id` as `pmid` FROM `types_of_pages`, `pages`,`profiles` WHERE `pages`.`profile`=`profiles`.`id` AND ((`page_title` LIKE '%".$search."%')OR(`content` LIKE '%".$search."%') OR (`profiles`.`type_of_biz`=`types_of_pages`.`id` && `types_of_pages`.`type_of_page`LIKE '$biz_type%' && `profiles`.`town` LIKE '$town_to_search')) AND `active`='y' ORDER BY `page_title`,`content` Group By ASC LIMIT $offset, $rowsperpage"; I'm not really sure where the problem is, so wondered if you guys might be able to help. If you want an example of what it does, visit http://www.truro.com and search for "tennis". Thanks, Neil Quote Link to comment https://forums.phpfreaks.com/topic/265746-multiple-records/ Share on other sites More sharing options...
fenway Posted July 17, 2012 Share Posted July 17, 2012 That's because you want a UNION, not a JOIN. Quote Link to comment https://forums.phpfreaks.com/topic/265746-multiple-records/#findComment-1362009 Share on other sites More sharing options...
gerkintrigg Posted July 17, 2012 Author Share Posted July 17, 2012 I sorted it by using "DISTINCT" but I'm curious... what's a UNION? I've heard of a join before. Quote Link to comment https://forums.phpfreaks.com/topic/265746-multiple-records/#findComment-1362082 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.