List:General Discussion« Previous MessageNext Message »
From:bharani kumar Date:August 21 2009 6:34am
Subject:Write IF condition in Query , and mysql Search function
View as plain text  
Hi All ,

Am working on the autosuggestion program ....

SELECT $field2,$field1 FROM  $tblname where  locate('$q', $field2) > 0 OR
locate('$q', $field1) > 0  order by locate('$q', $field2),

$field2 limit " . ($pagesize * $page) . "," . $pagesize

This is my query ,
Example .... in my Database table .. am having values somthing like


My present act like ...

If user enter the   " d  "

then  It show the baroda(BD) as first row and Delhi as second result ....

So can u please guide me here

Also for clear vision please go this link

Select the Postal code in the Taxi From combo...

Then enter the l as keyword . then u will find the first are start with A
not an L ,

So my expectation is ,

Assume if user enter the L then i want the first result as start with L row
as out ... and if they enter LI then result must lilliput somthing like

Am fething columns are postcodename and postcodeCODE ......

IIn the search, the first preference must be  field *postcodename *if no
keyword match in the first column then go  second column *postcodeCODE *

Can u please tell me How to write query for this siutaion....


Write IF condition in Query , and mysql Search functionbharani kumar21 Aug
  • Re: Write IF condition in Query , and mysql Search functionShawn Green28 Aug