Jump to content

[SOLVED] php mysql search terms syntax


redarrow

Recommended Posts

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'";
?>

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/136414-solved-php-mysql-search-terms-syntax/
Share on other sites

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%'";
?>

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.

 

 

 

 

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";
?>

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";

?>

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.