MySQL Forums
Forum List  »  Docs

mysql query
Posted by: shatarupa roy
Date: November 11, 2005 06:08AM

I have address book of some areas,i want to search data by first name or by last name or by block or by home no or by phone no in ascending order by frist name.
So i did following thing ,
$sql_query = "SELECT distinct * FROM addressbook WHERE ADD_ID LIKE '%' ";


if ($fname <>"")
{
$sql_query=$sql_query . " AND FIRST_NAME Like '" .$fname ."%'";
}
if ($lname <>"")
{
$sql_query=$sql_query . " AND LAST_NAME Like '" .$lname ."%'";
}
if ($block <>"")
{
$sql_query=$sql_query . " AND BLOCK Like '" .$block ."%'";
}
if ($phone <>"")
{
$sql_query=$sql_query . " AND PHONE_1 Like '" .$phone ."%'";
}
if ($address <>"")
{
$sql_query=$sql_query . " AND ADDRESS_1 Like '" .$address ."%'";
}
$sql_query .= " ORDER BY FIRST_NAME";
session_register('query_ref');

but their has some problem whice giving me ambiguius(incorrect) data.
please suggest.



Edited 2 time(s). Last edit at 11/11/2005 06:16AM by shatarupa roy.

Options: ReplyQuote


Subject
Views
Written By
Posted
mysql query
4065
November 11, 2005 06:08AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.