redarrow Posted December 10, 2008 Share Posted December 10, 2008 let say we had a database of facebook. Now let say we had two tables facebook_usera and another called facebook_userb, and the two fields being searched are called users. Now lets search the two table for the name john. Is this valid to search the two database fields for user john. <?php $sql="SELECT facebook_usera.users as A,facebook_userb.users as B FROM facebook_usera, facebook_userb WHERE A LIKE='john' OR B LIKE='john'"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/136414-solved-php-mysql-search-terms-syntax/ Share on other sites More sharing options...
premiso Posted December 10, 2008 Share Posted December 10, 2008 No, invalid sql. The following would work. <?php $sql="SELECT facebook_usera.users as userA,facebook_userb.users as userB FROM facebook_usera A, facebook_userb B WHERE A.users LIKE '%john%' OR B.users LIKE '%john%'"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/136414-solved-php-mysql-search-terms-syntax/#findComment-711842 Share on other sites More sharing options...
redarrow Posted December 10, 2008 Author Share Posted December 10, 2008 Thank u now how can u get the correct search where the search term is in alphabetical order. in database u got ab abbc abbbc If i wanted to search for ='%abby%' ill get returned abby only. but i want any think shown in alphabetical order any a words any ab words any abb words So how do you get distinct alphabetical searches and correct results... please example be grate cheers mate... i want anything shown in alphabetical order relating to the search word. Quote Link to comment https://forums.phpfreaks.com/topic/136414-solved-php-mysql-search-terms-syntax/#findComment-711855 Share on other sites More sharing options...
premiso Posted December 10, 2008 Share Posted December 10, 2008 Alphabetized <?php $sql="SELECT facebook_usera.users as userA,facebook_userb.users as userB FROM facebook_usera A, facebook_userb B WHERE A.users LIKE '%john%' OR B.users LIKE '%john%' order by a.users, b.users"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/136414-solved-php-mysql-search-terms-syntax/#findComment-711872 Share on other sites More sharing options...
redarrow Posted December 10, 2008 Author Share Posted December 10, 2008 Last question and thank you. Have you ever used this type of full text search if so what it all mean cheers.. yes i read the manual but the brain fried... <?php $sql="SELECT name, text, MATCH (text) AGAINST ('word1 word2 word3') AS score FROM table1 WHERE MATCH (text) AGAINST ('+word1 +word2 +word3' in boolean mode) order by score desc"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/136414-solved-php-mysql-search-terms-syntax/#findComment-711894 Share on other sites More sharing options...
premiso Posted December 10, 2008 Share Posted December 10, 2008 FullText is great as long as you have alot of data, if your search terms return more than 50% (i think its 50%) of the results, it comes out false (I think). But I have not used FullText in a while, I am not exactly I can answer your question. Quote Link to comment https://forums.phpfreaks.com/topic/136414-solved-php-mysql-search-terms-syntax/#findComment-711897 Share on other sites More sharing options...
redarrow Posted December 10, 2008 Author Share Posted December 10, 2008 Thank you anyway your grate 10/10 Have a grate xmas m8... Quote Link to comment https://forums.phpfreaks.com/topic/136414-solved-php-mysql-search-terms-syntax/#findComment-711901 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.