Back to list
Views:   7.1K
Replies:  1
Archived

An example please on how to use a SQL LIKE in Spark 4.5 Platform

Can you guys show an example on how to perform a LIKE query in the where parameter?

I tried this:

where: "productid like '%@0%' param: "014"

I got back 0 rows.

Running this in TSQL in SQL management studio did yield back some rows

What should be the correct way to do this in Spark 4.5?
Parity Bit, Sep 12, 2013
Reply 1
Hello Parity Bit: 

The Art Shop has a example (where you search for products) that demonstrates the use of a SQL LIKE.
You'll find it in the Products action method in the ProductController.

I think where you got confused is the placement of the '%'.
It should be placed on the value, rather than the parameter, something like this:  

var products = db.Products.All( where: "ProductId LIKE @0", parms: "%014%" );

Hope this helps.
 
Jack Poorte, Sep 12, 2013


Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Licensing       EULA       Sitemap      
© Data & Object Factory, LLC.
Made with    in Austin, Texas.      Vsn 1.3.0