Solved

Search Criteria, Multiple Fields

Posted on 2010-11-17
2
325 Views
Last Modified: 2012-05-10
This code works fine, however, I can't seem to discover how to change it.  Right now, it pulls *everything from field_id127 and field_id_128 if either field_id127 or field_id_128 meet the search criteria.

WHAT I WANT to happen is, there will only be a return from a field if it matches the specific requirement, NOT IF either Or meet it. So, both may return a value if they meet the criteria, or one may only meet the criteria or maybe neither meet it and return 0.

$q = ("SELECT field_id_53, field_id_127, field_id_128 FROM exp_weblog_data WHERE
field_id_127 LIKE '%$gitcolor%' OR
field_id_128 LIKE '%$gitcolor%' OR
GROUP BY field_id_53")

Open in new window

0
Comment
Question by:rgranlund
2 Comments
 
LVL 8

Expert Comment

by:Kelvin81
ID: 34159382
I'm not too familiar with PHP

But if you need both conditions to be true, try using AND:

$q = ("SELECT field_id_53, field_id_127, field_id_128 FROM exp_weblog_data
WHERE
field_id_127 LIKE '%$gitcolor%'
AND field_id_128 LIKE '%$gitcolor%'
GROUP BY field_id_53")
0
 
LVL 58

Accepted Solution

by:
cyberkiwi earned 500 total points
ID: 34159390
rgranlund,

With respect, still looking for samples.  This issue would have been sorted days ago if you just put up some samples.

Here is another answer based on another interpretation of your requirements:

$q = ("
SELECT
field_id_53,
Case when field_id_127 LIKE '%$gitcolor%' then field_id_127 else 0 end field_id_127,
Case when field_id_128 LIKE '%$gitcolor%' then field_id_128 else 0 end field_id_128
FROM exp_weblog_data
WHERE field_id_127 LIKE '%$gitcolor%' OR field_id_128 LIKE '%$gitcolor%' OR
GROUP BY field_id_53
")
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now