Query syntax in Query Unit

13 May '15, 03:05 PM
2,854 Views
No Forum Badges

i need to write a query with "like" condition in a Query Unit. 

For example i need to write SQL to count how many records of the table user has username field like '%ma%'

In MySQL DB the syntax is:

select count(*) from user where username like '%ma%'

Which is the syntax i need to write using an input parameter instead of 'ma' string in a "query unit" SQL query ?

Thanks

 

 
x 0
Follow
Answer Answer at this question and get points!
No Forum Badges

Hi Ombretta. 

I used :nameInput but i don't know the syntax to use "like" operator in conjunction with the parameter :nomeInput.

Thanks

 
x 1
Forum Expert - Level 5

Hi Luca,
to use the like operator with the input parameter you can use the following sintax:

where username like CONCAT ('%', :nameInput, '%')

Best regards,

Ombretta Malinverno

 
x 1
Forum Expert - Level 5

Hi Luca,
to use an input value in a query the sintax is the follow:

:nameInput

you can see an example of a query sintax in the article "Getting started with the Query Unit" in the "Working with the Update Mode" section of the following article http://www.webratio.com/learn/learningobject/getting-started-with-the-query-unit-v-72.

Best regards,
Ombretta Malinverno

 
x 0
Answer at this question and get points!