Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 28th, 2008, 02:02 PM
Authorized User
Points: 483, Level: 7
Points: 483, Level: 7 Points: 483, Level: 7 Points: 483, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2007
Location: Edgewood, NY, USA.
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??

Reply With Quote
  #2 (permalink)  
Old July 28th, 2008, 02:05 PM
Authorized User
Points: 483, Level: 7
Points: 483, Level: 7 Points: 483, Level: 7 Points: 483, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2007
Location: Edgewood, NY, USA.
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!????

Reply With Quote
  #3 (permalink)  
Old July 28th, 2008, 02:07 PM
Authorized User
Points: 483, Level: 7
Points: 483, Level: 7 Points: 483, Level: 7 Points: 483, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2007
Location: Edgewood, NY, USA.
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.

Reply With Quote
  #4 (permalink)  
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!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 01:53 PM.


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