티스토리 뷰
반응형
선택문 (SELECT)
//기본 형식 ( select...from...where...order by...(asc : 오름차순, desc : 내림차순)
@"select * from DataBase where NAME = ''썩소천사"
//마지막 아이디 값 가져오기
NSArray *resData;
@"select last_insert_rowid() as lastId from DataBase"
int lastID = [[[resData objectAtIndex:0] objectForKey:@"lastId"] intValue];
//테이블 전체 데이터를 가져올 때
@"select * from DataBase"
//데이터 가져오면서 정렬하기
@"select * from DataBase order by _month, _day asc"
//테이블의 특정 컬럼만 가져올 때 (속도, 데이터 저장공간 면에서 더 효율적이다)
@"select _year, _month, _day from DataBase"
//조건값으로 가져오기( 2011.6.15일 데이터 가져오기)
@"select * from DataBase where _year=2011 and _month=6 and _day = 15"
//( 2011.6월 1일부터 15일까지의 데이터 가져오기)
@"select * from DataBase where _year=2011 and _month=6 and _day between 1 and 15"
//다중 조건문과 오름 차순 정렬을 통해 _title 컬럼 값만 가져오기 조건문( and, or )을 통해 범위 지정이 가능하다.
@"select _title from DataBase where _year < 2011 or _year <= 2011 and _month < 6 or _day < 15 order by _year, _month, _day asc"
반응형
'iOS > 자료정리' 카테고리의 다른 글
[iPhone]APNS push 구현 자료 정리 (0) | 2011.07.06 |
---|---|
[iPhone]MPMediaPickerController, MFMessageComposeViewController, MFMailComposeViewController (0) | 2011.06.21 |
[iPhone]NSMutableArray, NSArray (0) | 2011.06.10 |
[iPhone]AVAudioRecorder (음성 녹음) /*.wav로 변환/ (3) | 2011.05.30 |
[iPhone]화면 회전 (0) | 2011.04.13 |
댓글
반응형