Web Design and Development Forums

Search Bar CONCAT query

This is a discussion on "Search Bar CONCAT query" within the MySQL section. This forum, and the thread "Search Bar CONCAT query are both part of the Databases category.


Go Back   Webforumz.com > Databases > MySQL

Welcome to Webforumz.com.
Register Now Register now!

Reply
 
LinkBack Thread Tools Rate Thread
Old May 9th, 2008, 11:11   #1 (permalink)
Junior Member
 
Join Date: Feb 2008
Location: UK
Posts: 10
Search Bar CONCAT query

Hi People,

If anyone can help please?

I've got a search bar and for example im trying to search the name billy brown.

this is my query:

$query = "SELECT id, CONCAT(forename,' ',surname) AS Com

FROM contacts

WHERE CONCAT(contacts.forename = '$search' AND contacts.surname = '$search') || contacts.forename LIKE '$search%' || contacts.surname LIKE '$search%'";

The outcome to all this is that it will display the name "Billy Brown" even if i only type Billy or Brown, this works but what if someone types in the whole name "Billy Brown" no results are displayed.

Any solutions?

Thanks

meth8200 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 9th, 2008, 12:40   #2 (permalink)
Nerdy Moderator
 
CloudedVision's Avatar
 
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 520
Blog Entries: 4
Re: Search Bar CONCAT query

Moved to MySQL Forum
__________________
Take it easy

Other Road Design

WebForumz Moderator: HTML | Javascript | PHP
CloudedVision is online now  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 13th, 2008, 22:00   #3 (permalink)
Junior Member
 
Join Date: Feb 2008
Location: Michigan
Posts: 23
Re: Search Bar CONCAT query

I think your where clause is messed up - try

WHERE contacts.forename = '$search' OR
contacts.surname = '$search' OR
CONCAT(contacts.forename, ' ', contacts.surname) = '$search'
awatson is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Partial Search Query Aerdan MySQL 5 Nov 7th, 2007 15:26
Query Strings and concat magnetica JavaScript Forum 1 Aug 22nd, 2007 13:22
MySQL query query dangergeek MySQL 3 Apr 12th, 2007 12:45
search query to google as <iframe> source vHTML JavaScript Forum 1 Jan 14th, 2007 17:52



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 17:24.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59