Username Remember Me?
Password   forgot password?
   
   
How to pass a variable to ths adsql query? 
Posted: 05 December 2016 05:03 PM   [ Ignore ]  
Master
RankRankRank
Total Posts:  51
Joined  2010-05-27

Dear Developer,

This is a query to get the record where the name is like Joe.
s = sdsql(database1, ‘select * from table1 where name like ‘’Joe’’’ )?

Now, I want a variable to pass this query.
var1=’Joe’
How to define this query to pass var1 into it?

any ideas?

Thanks!

Profile
 
 
Posted: 05 December 2016 06:00 PM   [ Ignore ]   [ # 1 ]  
Administrator
Avatar
RankRankRankRank
Total Posts:  356
Joined  2008-04-26

just concatenate the query string with your specific variable using standard Matlab horizontal concat (square brackets):

>> s=sdsql(d,'select * from data where name like "Joe";')
1 by 2 set in 'test2.db':
SQL='select * from data where name like "Joe";'
>> val='Joe'

val =

Joe

>> s=sdsql(d,['select * from data where name like "' val '";'])
1 by 2 set in 'test2.db':
SQL='select * from data where name like "Joe";'
>> +s

ans 


    
[1]    'Joe'

Hope it helps

Pavel

Profile