4. SELECT
● SELECT Persons.LastName, Persons.FirstName,
Orders.OrderNo FROM Persons INNER JOIN
Orders ON Persons.P_Id=Orders.P_Id ORDER BY
Persons.LastName
● SELECT * FROM Persons WHERE LastName
BETWEEN 'Hansen' AND 'Pettersen'
● SELECT Customer,OrderDate,SUM(OrderPrice)
FROM Orders GROUP BY Customer,OrderDate
6. UPDATE
● UPDATE Persons SET Address='Nissestien 67',
City='Sandnes' WHERE LastName='Tjessem' AND
FirstName='Jakob'
● UPDATE Persons SET Address='Nissestien 67',
City='Sandnes'
7. DELETE
● DELETE FROM Persons WHERE
LastName='Tjessem' AND FirstName='Jakob'
13. Never mind, we have......
execSQL * 2
db.execSQL("CREATE TABLE IF NOT EXISTS person (personid integer primary
key autoincrement, name varchar(20), age INTEGER)");
14. and
rawQuery * 4
db.rawQuery("select count(*) from person", null);
34. How to use...
private void initDatabase() {
helper = new DaoMaster.DevOpenHelper(this, NAME, null);
master = new DaoMaster(helper.getWritableDatabase());
session = master.newSession();
cityDao = session.getCityDao();
townDao = session.getTownDao();
storeDao = session.getStoreDao();
}
35. How to use...
cityDao.insert(new City(1L, "台北市"));
storeDao._queryTown_Stores(townId).isEmpty()
town =
townDao.queryBuilder().where(TownDao.Properties.Name.eq(
"新莊區"), TownDao.Properties.CityId.eq(5)).unique();
36. At first, generate code to use it.
public static void main(String[] args) {
schema = new Schema(4, "tw.kewang.smile319.model");
addCity();
addTown();
addStore();
new DaoGenerator().generateAll(schema, "../Prj/src-gen");
}
37. At first, generate code to use it.
private static void addTown() {
Entity town = schema.addEntity("Town");
town.addIdProperty().columnName("id");
town.addStringProperty("name").notNull();
town.addDoubleProperty("latitude");
town.addDoubleProperty("longitude");
Property cityId =
town.addLongProperty("cityId").notNull().getProperty();
ToMany cityToTowns = city.addToMany(town, cityId);
cityToTowns.setName("towns");
}
39. Generator contains...
● A schema at least
● A schema has many entities (models)
● A entity has many property (data type, not null,
autoincrement, index......etc.)
● 2 entities have a relationship (optional)
● Project has a leader
● Leader belongs to a project