블로그 이미지
송시혁

calendar

1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

Notice

Tag

Recent Post

Recent Comment

Recent Trackback

Archive

2018. 6. 18. 13:42 네트워크/database실습

생성한 테이블 



정가 20000원이상 책.

=> select * from book where price >= 20000;


책의 평균 가격

=>  select avg(price) from book;



gmail 이메일을 사용하는 저자

=> select name from author where email like '%gmail%';






아직 책을 발간하지 않은 저자

author_id가 일치하는 것인 발행된 저자이고 아닌것이 미발행 저자이다. 그러므로 

author로 join시키면 된다. 


select author.name, book.title from author left join book on author.author_id=book.author_id where 

   book.title is NULL;


출간된 저자목록과 price*qty를 출력

=>select  book.title,author.name, book.price*book.qty as 'price*qty from author inner join book on author.author_id=book.author_id;


book.price*book.qty = 테이블 book에 있는 price와 qty 곱한값을 출력하면서 

as 'price*qty'를 하여 속성명을 정해줌. 


book.author_id = author.author_id이라는 조건을 통하여 출력.



cc -E -o main main.c

=> -E 옵션은 전처리기 옵션이다. 해당 실행파일인 main을

    전처리만 한 실행파일로 만들어준다.



./main(실행파일이름)을 실행하면 아래 코드가 보인다.

#define하였던 setp, lower.. 등이 전부 숫자로 치환되었다. 


분명히 코드에는 
#define LOWER 0
#define STEP    20
#define UPPER 300
이였다. 

그것을 먼저 전처리하여 치환한다. 실제 컴파일은 저렇게 숫자로 되어있음을 알 수 있다. 








posted by 송시혁