Using MySql- Select
1 view (last 30 days)
Show older comments
Hi,
I have a problem at this line:
['select count(*) from gene_threepoints where Window_size=30 and leftSeq>= ''',x(1),''' and leftSeq< ''',x+jump,''' and middleSeq>= ''',y,''' and middleSeq< ''',y+jump,''' and rightSeq>= ''',z,''' and rightSeq< ''',z+jump,''' and GENE_id= ''' ,num2str(GENE_id_Array{Loop}),'''']
When I enter this line in the workspace, I get null at the x,y,z values. (This line is inside a triple for of x,y,z).
like this:
select count(*) from gene_threepoints where Window_size=30 and leftSeq>= ' ' and leftSeq< '
' and middleSeq>= ' ' and middleSeq< '
' and rightSeq>= ' ' and rightSeq< '
' and GENE_id= '112'
Windows_size, leftSeq, middleSeq ,rightSeq and GENE_id are columns in the database
What is the mistake?
Thanks in advance for any help!
0 Comments
Accepted Answer
Walter Roberson
on 29 Dec 2011
I suggest rewriting it using sprintf:
sprintf('select count(*) from gene_threepoints where Window_size=30 and leftSeq>=%d and leftSeq<=%d and middleSeq>=%d and middleSeq<%d and rightSeq>=%d and rightSeq<%d and GENE_ID=''%d''', x(1), x+jump, y, y+jump, z, z+jump, GENE_id_Array{Loop})
Caution: you used x(1) which most people would interpret as indicating that you expect x to have more than one element, and they would then wonder whether x+jump is going to be correct there.
Your essential problem is that x and so on are numeric, and you are concatenating those numeric values on to a string without having converted the numeric values to string.
0 Comments
More Answers (1)
See Also
Categories
Find more on Database Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!