MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old May 24th, 2000, 09:00 AM
starspider starspider is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 3 starspider User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hello,
I have a huge problem with an sql query. I have been working on this now for about one week and cant get it solved.
The following query doesnot work, well, it does not cause and error but its not working how i want it to.

$query = "SELECT * FROM links WHERE (name LIKE '%" . $search . "%' OR link LIKE '%" . $search . "%' OR besch LIKE '%" . $search . "%' OR keyword LIKE '%" . $search . "%') AND (active = 1)";

So, this query is supposed to search in a database for a certain keyword. It works almost quite fine. Here are the problems: The query doesnot care wether active is one or anything else. Second: The query doesnot search in "besch". If the keyword is in "besch" and nowhere else the records doesnot get selected. Anyone an idea how to handle this?! I am getting really frustrated with this... I think I put all the ANDs and ORs in wrong order...

[This message has been edited by starspider (edited May 24, 2000).]

Reply With Quote
  #2  
Old May 25th, 2000, 06:11 AM
Shiju Rajan's Avatar
Shiju Rajan Shiju Rajan is offline
.Net Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: London
Posts: 987 Shiju Rajan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 9
Send a message via MSN to Shiju Rajan Send a message via Yahoo to Shiju Rajan

try the following:

$query="Select * from links where (name like "%$search%" or link like "%$search%" or besch like "%$search%" or keyword like "%$search%") AND (active = 1)";

if active is varchar then use active='1'




------------------
SR -
shiju.dreamcenter.net

"The fear of the LORD is the beginning of knowledge..."

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > MySQL QUERY


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway