0 Replies Latest reply on Nov 5, 2010 11:03 AM by locollama

    IN operator in sqlite local database

    locollama

      New to the whole sql world, im building my first database air application.

       

      I have a database that i'm working with Asynchronously.

       

      I'm trying to get a sql result that gives me a list of all the entries (rows) that match a predefined list or array.

       

      I would like to use LIKE but that only returns to me one row in my database.

      I found the operator IN but i'm not getting the desired results

       

      with this following code

      i get multiple rows results.

       

      private function Add():void
                  {
                      var q:SQLStatement = new SQLStatement();
                      q.text = "SELECT * FROM testdb WHERE Symbol IN ('Apple', 'Orange', 'Cat');
                                     q.sqlConnection = conn;
                      q.addEventListener( SQLEvent.RESULT, Add2);
                      q.addEventListener( SQLErrorEvent.ERROR, queryError );
                      q.execute();
                  }
                 
                  private function Add2( event:SQLEvent ):void
                  {
                      var r:SQLResult = SQLStatement(event.currentTarget).getResult();
                      dg.dataProvider = r.data;
                   
                  }

       

       

       

      If i use the LIKE statement then the lettercase of the word doesnt matter but i get only one result in my Datagrid.

       

      If i try to use a parameter, my ouput is an empty grid.

      if i change to the testArray variable, i receive the same thing.

       

                public var testString:String = "Orange, Apple, CAT";

                public var testArray:Array = new Array("Orange","Apple", "CAT");

                   private function Add():void
                  {
                      var q:SQLStatement = new SQLStatement();
                      q.text = "SELECT * FROM testdb WHERE Symbol IN ?";
                      q.parameters[0] = testString;
                      q.sqlConnection = conn;
                      q.addEventListener( SQLEvent.RESULT, Add2);
                      q.addEventListener( SQLErrorEvent.ERROR, queryError );
                      q.execute();
                  }
                 
                  private function Add2( event:SQLEvent ):void
                  {
                      var r:SQLResult = SQLStatement(event.currentTarget).getResult();
                      dg.dataProvider = r.data;
                   }

       

       

      IS there a way to get the IN operator to work with a parameter calling an array or string?

      IS there a way to get multiple results from a LIKE operator?

       

      thanks for the help in advance