KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

MySQL - How can I use the LIKE operator? #730

Open JTBB opened this topic on on Mar 6, 2019 - 3 comments

JTBB commented on Mar 6, 2019

Hi support,

How can I use the LIKE operator? I want to do this:

WHERE OrderRelationID LIKE '%xyz%' but then using a parameter, see below. What is the correct syntax please?

SELECT OrderID, OrderDate, OrderTypeID FROM Orders
WHERE
 __ OrderRelationID LIKE :OrderRelationID__
AND
(OrderDate > :startDatePicker AND OrderDate < :endDatePicker)
KoolReport commented on Mar 7, 2019

You can do:

$this->src("mysource")->query("
    SELECT OrderID, OrderDate, OrderTypeID FROM Orders
    WHERE
    OrderRelationID LIKE :OrderRelationID
")->params(array(
    ":OrderRelationID"=>"%".$this->params["OrderRelationID"]."%"
))
...
JTBB commented on Mar 7, 2019

That works great! Thanks!!

KoolReport commented on Mar 7, 2019

Awesome!

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
solved

None