Select to view content in your preferred language

Query.Where SQL Statement

4446
4
Jump to solution
01-03-2015 05:20 AM
mohamedsaad1
New Contributor

i have a problem writing a sql where statment ,

here is my code( working fine ) :

var cadname = dom.byId("CADName").value ;
var fromno= dom.byId("fromNo").value ;
var tono= dom.byId("toNo").value ;
 

query.where = "   CAD_NAME=   '" + cadname + "'    AND    LAND_NUMBER=" + fromno ;

--------------------

the above code working fine , but i want to add more " AND " Statement , so the query result is between " fromno" and " endno" .

i want the statement looks like

query.where = "   CAD_NAME=   '" + cadname + "'    AND    LAND_NUMBER>" + fromno       AND      LAND_NUMBER< " +tono  ;

i think the problem in the sequence of single and double quotes.      

Thank you

M-Sa3d

0 Kudos
1 Solution

Accepted Solutions
RichardFairhurst
MVP Honored Contributor

You forgot to put a + and open quotes after the fromno variable.  It should be:

query.where = "CAD_NAME= '" + cadname + "' AND LAND_NUMBER > " + fromno + " AND      LAND_NUMBER < " + tono;

View solution in original post

4 Replies
RichardFairhurst
MVP Honored Contributor

You forgot to put a + and open quotes after the fromno variable.  It should be:

query.where = "CAD_NAME= '" + cadname + "' AND LAND_NUMBER > " + fromno + " AND      LAND_NUMBER < " + tono;

mohamedsaad1
New Contributor

Thank you Richard

0 Kudos
josetorres2
New Contributor

Richard Fairhust, would you mind helping me out with the same issue. I am currently enrolled in a GIS class and having a really tough time. THanks so much.

0 Kudos
RichardFairhurst
MVP Honored Contributor

Did you create your own post with the code that is not working?  You should and then link to it in a post here so I will be notified.

0 Kudos