首页 > 解决方案 > How to select two table columns in the same for loop

问题描述

Im trying to get two variables from the same table in a for loop, so far the first one works but when i try to do the second one it gives me me an error, i dont understand why its wrong?

The uncommented code works just fine, but the commented code gives me errores, they are the same except for the column im selecting from.

List<Events> eventlist = SQLite.select().from(Events.class).queryList();

        int size = eventlist.size();
        System.out.println(eventlist.size());
        int id = 1;

        for (int i = 0; i < size; i++) {
            System.out.println(i);
            System.out.println("id " + id);

            String st = valueOf(SQLite.select(Events_Table.init_date)
            .from(Events.class).where(Events_Table.id.eq(id)).querySingle());

            //ERROR HERE
            //String ed = valueOf(SQLite.select(Events_Table.end_date)
            .from(Events.class).where(Events_Table.id.eq(id)).querySingle());


            String start = funt.formatDate(st);
            //String end = funt.formatDate(ed);

            System.out.println("Stdate: " + start);
            //System.out.println("edDate: " + end);
            //singleE.add(start);
            id++;
        }

this is the current output

System.out: 309
System.out: id 310
System.out: Stdate: 2018-01-12

i would like the same but with the edDate, both at the same time

标签: for-loopselectdbflow

解决方案


推荐阅读