Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
|
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 28th, 2008, 02:02 PM
Authorized User
 
Join Date: Apr 2007
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default Multiple LIKE statements

Hello Programmer Gurus!
I am trying to query my databsse of 10 ten fields for a search page.
When I use:
Model1 like '" & Search & "%' AND Model2 like '" & Search & "%'AND AND Model2 like '" & Search & "%'

I only get results from the first like statement. I know I have matching criteria in the other fields. any ideas??

 
Old July 28th, 2008, 02:05 PM
Authorized User
 
Join Date: Apr 2007
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Actually my error from above! I get NO results! but if I remove the last "Like" statement, The first one works fine!????

 
Old July 28th, 2008, 02:07 PM
Authorized User
 
Join Date: Apr 2007
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ahhhhhhhhhhhh!

Sorry!
Model1 like '" & Search & "%' AND Model2 like '" & Search & "%'AND Model2 like '" & Search & "%'

Above had an extra "and".... Still doesnt work though.

 
Old December 17th, 2008, 03:38 PM
Registered User
 
Join Date: Dec 2008
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Solution

Select * FROM tablename WHERE (columnname1 like ('%ValueA%')) OR (columnname2 not like ('%ValueB%')) limit 10;

Good luck!





Similar Threads
Thread Thread Starter Forum Replies Last Post
if statements for multiple date checks melkin SQL Language 0 December 17th, 2007 09:53 AM
Multiple IIF Statements rohit_ghosh Access 2 May 7th, 2007 03:05 PM
Multiple IIF statements Corey Access 1 November 16th, 2006 05:25 PM
executing multiple statements jae_green PHP Databases 1 July 7th, 2003 02:19 PM
Multiple Insert Statements tp194 Classic ASP Databases 8 June 11th, 2003 01:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.