Shift + Tab : 선택된 줄을 탭 단위로 앞으로 이동
바로 내가 찾던 단축키
그외 단축키는 아래 블로그로 가세요.
http://blog.naver.com/yousilver23?Redirect=Log&logNo=50942552
2013년 7월 25일 목요일
2013년 7월 23일 화요일
[MySQL] You can't specify target table 'Customize' for update in FROM clause
insert 구문에서 에러가 났다.
에러메시지는 뭔소리인가..
구글링하니 한방에 나옴ㅋ
이 에러는 insert나 update를 하는 경우 서브쿼리의 FROM절에서 target 테이블과 동일한 테이블을 사용할 수 없다는 내용이다.
ㅋㅋ
UPDATE mytable_name
SET a='kim'
WHERE Exists ( SELECT* FROM ( SELECT id
FROM mytable_name
WHERE b=0
LIMIT 2 ) as temp
위와 같이 한 번 더 감싸줘야 한다.
[MySQL] Insert where not exists
Insert into Table1 (col1, col2)
select 'val1', 'val2' from Table2
where not exists
(
select col1, col2
from Table
where col1 = 'val1' and col2 = 'val2'
)
where not exists 문 아래 select 문에 값이 없을 때
Insert 처리 한다.
do0park.blog.me/40134359319
Insert 시 select 쓰지 않는 소스
http://www.dbforums.com/microsoft-sql-server/1640697-insert-where-not-exists.html
위 두 방법이 되지 않는 다면...
INSERT INTO Table(col1, col2, col3) SELECT col1, col2,col3 FROM DUAL WHERE NOT EXISTS ( SELECT col FROM Table WHERE col = val1)
value 대신 Select 문을 사용하여 Insert 진행하고 From Dual 즉 더미 Table 을 적어 주고,
Where not exists 문에 Select 문을 넣으면 동작한다.
select 'val1', 'val2' from Table2
where not exists
(
select col1, col2
from Table
where col1 = 'val1' and col2 = 'val2'
)
where not exists 문 아래 select 문에 값이 없을 때
Insert 처리 한다.
do0park.blog.me/40134359319
INSERT INTO propval (tocid, prop_id, pos, str_val) VALUES (tocid, 1, 0, 'No') WHERE NOT EXISTS (SELECT * FROM propval WHERE prop_id = 1)
Insert 시 select 쓰지 않는 소스
http://www.dbforums.com/microsoft-sql-server/1640697-insert-where-not-exists.html
위 두 방법이 되지 않는 다면...
INSERT INTO Table(col1, col2, col3) SELECT col1, col2,col3 FROM DUAL WHERE NOT EXISTS ( SELECT col FROM Table WHERE col = val1)
value 대신 Select 문을 사용하여 Insert 진행하고 From Dual 즉 더미 Table 을 적어 주고,
Where not exists 문에 Select 문을 넣으면 동작한다.
2013년 7월 16일 화요일
[MySQL] Insert 와 select 문 같이 써서 Insert 하기
Insert Into Select 를 사용하면 서, ColA 는 1로 넣고 싶을 때
아래와 같이 사용하면 된다.
INSERT INTO MyTable
(ColA,
ColB,
ColC)
SELECT 1,
colBB,
colCCFROM MyTable2
응용하여서, 하나의 칼럼에 Constant 값을 넣고 싶으면
Select 문에 넣고 싶은 칼럼에 Constant를 넣으면 됨
출처 : http://stackoverflow.com/questions/4989583/insert-combine-value-and-select
아래와 같이 사용하면 된다.
INSERT INTO MyTable
(ColA,
ColB,
ColC)
SELECT 1,
colBB,
colCCFROM MyTable2
응용하여서, 하나의 칼럼에 Constant 값을 넣고 싶으면
Select 문에 넣고 싶은 칼럼에 Constant를 넣으면 됨
출처 : http://stackoverflow.com/questions/4989583/insert-combine-value-and-select
2013년 6월 26일 수요일
[MFC] MySQL 함수 정리
CString query;
query.Format(" blur blur");
쿼리 실행
ado.ExecuteSQL(query, 0)
검색결과 개수
int count = ado.GetRecordCount();
컬럼 값 구하기
CString temp;
ado.GetFieldValue( column number, temp, _T(""));
다음 값 가져오기
ado.m_ptrRecordset->Moveext();
쿼리값 마지막 찾기
while(!ado.m_ptrRecordset->adoEOF)
{
다음 값 가져오기
ado.m_ptrRecordset->Moveext();
}
query.Format(" blur blur");
쿼리 실행
ado.ExecuteSQL(query, 0)
검색결과 개수
int count = ado.GetRecordCount();
컬럼 값 구하기
CString temp;
ado.GetFieldValue( column number, temp, _T(""));
다음 값 가져오기
ado.m_ptrRecordset->Moveext();
쿼리값 마지막 찾기
while(!ado.m_ptrRecordset->adoEOF)
{
다음 값 가져오기
ado.m_ptrRecordset->Moveext();
}
[DB] Query 정리
Select
Select Column From Table where Col1 = xx and Col2 = yy or Col3 = zz
Insert
Insert Into Table (Col1, Col2, Col3) VALUES (Co1, Col2, Col3)
String의 경우 ' ' 혹은 " " 로 감싸준다. "이순신" '이순신'
Update
밋
Update tabe set col1 = val1 , co2 = val2 where some_col = som_val;
Add a Column
Alter Table contacts Add email VARCHAR(60);
Column 가져오기
Show columns from Table;
Select Column From Table where Col1 = xx and Col2 = yy or Col3 = zz
Insert
Insert Into Table (Col1, Col2, Col3) VALUES (Co1, Col2, Col3)
String의 경우 ' ' 혹은 " " 로 감싸준다. "이순신" '이순신'
Update
밋
Update tabe set col1 = val1 , co2 = val2 where some_col = som_val;
Add a Column
Alter Table contacts Add email VARCHAR(60);
Column 가져오기
Show columns from Table;
2013년 6월 25일 화요일
[C++] Vector Erase
|
출처: http://www.cplusplus.com/reference/vector/vector/erase/
피드 구독하기:
글 (Atom)