Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Query Syntax With LIKE

Posted on 2014-09-20
4
165 Views
Last Modified: 2014-09-20
I have a variation on a question I asked earlier .  How do I use LIKE in the following query and then in creating the variables?
Line 7 and Line 20;

 	$check_alt  = 	"SELECT meta_value, meta_key
					FROM wp_woocommerce_order_itemmeta
					WHERE (meta_key = 'Bicycle Info - Primary Operator First Name'
					OR meta_key = 'Bicycle Info - Primary Operator Last Name'
					OR meta_key = 'Bicycle Info - Bicycle Serial Number'
					OR meta_key = '_line_total'
					OR meta_key LIKE 'Custom Price - Bicycle Liability %')
					AND order_item_id = :order_id ";
 	
		$checking_alt = $pdo->prepare($check_alt);		
		$checking_alt->execute(array(':order_id' => $order_id)) or die(print_r($checking_alt -> errorInfo()));
		$res_alt = $checking_alt->fetchAll();	
				
				if ($res_alt) {
					
					foreach ($res_alt as $rows)  {
						if($rows->meta_key == "_line_total") { 
							$total = $rows->meta_value;
						}
						elseif($rows->meta_key == 'Custom Price - Bicycle Liability')	{
							$total_liabil = $rows->meta_value;
						}			
						} 						           
					}		
				}	
			}

Open in new window

0
Comment
Question by:rgranlund
  • 2
4 Comments
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 150 total points
ID: 40334664
0
 
LVL 7

Author Comment

by:rgranlund
ID: 40334683
@dave, but it does not address how I write line 20  ???
0
 
LVL 58

Accepted Solution

by:
Gary earned 350 total points
ID: 40334690
if(strpos($rows->meta_key,"string-to-find") !== FALSE){
...
}

Open in new window

0
 
LVL 7

Author Comment

by:rgranlund
ID: 40334705
Thanks!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

791 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