Solved

Query Syntax With LIKE

Posted on 2014-09-20
4
162 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

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…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
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 count occurrences of each item in an array.

772 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