Author Topic: Building search for MySQL and need help with Query  (Read 1095 times)

0 Members and 1 Guest are viewing this topic.

Offline $usernameTopic starter

  • Enthusiast
  • Posts: 159
  • <?PHP echo "Live by it"; ?>
    • View Profile
Building search for MySQL and need help with Query
« on: January 02, 2008, 09:36:44 PM »
Hello Everyone,
    I am trying to build a query to search my tables. What I am getting is it will find all of the info from all fields  and then when I out put it in PHP it will show up as many times as it found it in the same table field.

So here is example
First Name | LastName | email|
Timmy       | Billy         | timmy@gmail.com
__________________
So when I search it shows the same search 2 times
I need to know if there is a way to restrict the search so it does not show 1 column 2 times when it searches? Or is this something I have to do in PHP?
Code: [Select]
$query213 = "SELECT * FROM `tdb_` . `contacts`, `tdb_` . `account` WHERE ( contacts.ContactFname LIKE
CONVERT( _utf8 '%$trimmed%' USING latin1 ) COLLATE latin1_swedish_ci OR contacts.ContactLname LIKE
CONVERT( _utf8 '%$trimmed%' USING latin1 ) COLLATE latin1_swedish_ci OR contacts.ContactPhone LIKE)"


Thanks for any help
Brett
If you think it was easy, you did not learn anything. Try something harder.

Offline fenway

  • MySQL Si-Fu / PHP Resident Alien
  • Global Moderator
  • 'Mind Boggling!'
  • *
  • Posts: 15,444
  • Gender: Male
    • View Profile
Re: Building search for MySQL and need help with Query
« Reply #1 on: January 03, 2008, 09:47:27 AM »
That's because you have no join condition between those 2 tables ... has nothing to do with the "searching" perse.
:anim_rules: Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.