I have a big record set in a table. I switched from Like %% to Match Against and data seems to return faster. I've run into 2 quirks I didn't exect and spent all day messing with getting things working right - I give up and looking for help now.
First-
When using LIKE and the keyword field is blank, as expected all records are returned since there is no word given to filter on. The return count = all the records in the table.
When using MATCH and the keyword field is blank, it literally looks for any records that are intentionally blank and of course, finds no blank records so the return count = 0.
What is the syntax to return all the records when the keyword field is blank using the MATCH method to query?
Second-
I have 2 of 10 Case statements that have multiple criteria applied. For example:
Case 'Example1':
if ($sKey = "") $sMatchType = "NOT MATCHED";
$sTable = 'ClassifiedsAdvertisements';
$aWhereKey[] = "{$sMatchType}(Subject, Message) AGAINST ('$sKey')";
$sApproved = "`ClassifiedsAdvertisements`.`Status`= 'active'";
$sSqlOrderBy = 'ORDER BY `Sort1` ASC';
$sSclassified = "`ClassifiedsSubs`.`IDClassified` = '16'
OR `ClassifiedsSubs`.`IDClassified` = '15'
OR `ClassifiedsSubs`.`IDClassified` = '10'
OR `ClassifiedsSubs`.`IDClassified` = '21'
OR `ClassifiedsSubs`.`IDClassified` = '18'";
break;
When I run this query, regardless if $sKey is blank or has a word value, this Case returns a data records. If the $sSclassified line was only $sSclassified = "`ClassifiedsSubs`.`IDClassified` = '16' then 0 records are returned if the keyword was left blank.
I don't understand the logic. Can someone please help me correct these issues? I have googled and read and googled and read plus tried all different ways to tweak the code and still it is broken.
Thank you in advance.