메뉴 닫기

[mysql] 쿼리에서 조건문 사용

if 문, case 문, ifnull문

IF 문

형식 : if ( 조건문, 참일때 값, 거짓일때 값)
EX)  select member_id, if ( isnull(birthday), ‘-‘, birthday ) from member
설명 – 멤버 테이블에서 아이디(member_id) 와 생일을 뽑는데 null 일경우는 – 를 출력,
아니면 생일을 출력
 
 

Case 문

형식 :  case (조건 또는 값)
when 값1 then 표시값
when 값2 then 표시값
else 표시값
end
EX)   select case a when ‘1’ then a when ‘2’ then b else c end from table_name
설명 – a 값이 ‘1’이면 a, ‘2’ 이면 b, 둘다 아닐경우 c 를 출력
 
 

ifnull문 ( mysql 에서 사용 )

형식 : ifnull ( 값1, 값2)
EX ) select ifnull ( price, 0 ) from books
설명 – price 값이 Null 이면 0을, Null 이 아니면 price 값을 출력
 
 

isnull문 ( MS-SQL 에서 사용 )

형식 : ifnull ( 값1, 값2)
EX ) select isnull ( price, 0 ) from books
설명 – price 값이 Null 이면 0을, Null 이 아니면 price 값을 출력
 
 

NVL문 ( Oracle 에서 사용 )

형식 : NVL ( 값1, 값2)
EX ) select nvl ( price, 0 ) from books
설명 – price 값이 Null 이면 0을, Null 이 아니면 price 값을 출력

40 Comments

  1. g have

    I like the valuable information you provide in your articles.
    I’ll bookmark your blog and check again here regularly.
    I am quite sure I’ll learn many new stuff right here!
    Best of luck for the next!

  2. rsacwgxy g

    Hi there, just became alert to your blog through Google, and found that
    it’s really informative. I’m gonna watch out for brussels.

    I’ll be grateful if you continue this in future.
    Numerous people will be benefited from your writing. Cheers!

  3. Claudio Vanderzwaag

    I simply want to say I am just very new to blogging and really savored your web site. More than likely I’m want to bookmark your blog post . You really have terrific article content. Many thanks for sharing with us your web site.

  4. viagra buy now

    The next time I read a blog, I really hope that it does not disappoint me as high as this one. I indicate, I understand it was my option to review, however I actually thought youd have something interesting to claim. All I hear is a number of yawping about something that you might deal with if you werent too busy trying to find interest.

  5. read what he said

    I discovered your blog website on google as well as check a few of your early posts. Continue to keep up the very good operate. I simply extra up your RSS feed to my MSN News Visitor. Looking for forward to learning more from you in the future!?

  6. wrought iron security doors

    My developer is trying to persuade me to move to .net from PHP. I have always disliked the idea because of the costs. But he’s tryiong none the less. I’ve been using WordPress on various websites for about a year and am anxious about switching to another platform. I have heard very good things about blogengine.net. Is there a way I can import all my wordpress content into it? Any help would be really appreciated!

  7. cbd sleep aid for sale

    Oh my benefits! a remarkable write-up guy. Thank you Nonetheless I am experiencing problem with ur rss. Don?t understand why Incapable to sign up for it. Is there any person obtaining similar rss problem? Any individual that recognizes kindly respond. Thnkx

  8. cbd oil for sale to pennsylvania

    There are absolutely a great deal of details like that to think about. That is a wonderful point to raise. I provide the thoughts over as basic motivation yet plainly there are questions like the one you raise where the most crucial thing will be operating in truthful good faith. I don?t understand if finest techniques have emerged around things like that, yet I make sure that your job is clearly identified as a level playing field. Both kids and also ladies really feel the impact of just a moment?s pleasure, for the remainder of their lives.

  9. best cbd for dogs 100lbs with cancer

    I?m satisfied, I should state. Truly rarely do I encounter a blog that?s both informative and amusing, and also let me tell you, you have struck the nail on the head. Your suggestion is superior; the problem is something that inadequate individuals are talking intelligently about. I am very pleased that I came across this in my search for something relating to this.

  10. best website hosting

    It’s a pity you don’t have a donate button! I’d most certainly
    donate to this fantastic blog! I guess for now i’ll settle for book-marking and adding your
    RSS feed to my Google account. I look forward to
    brand new updates and will talk about this website with my Facebook group.
    Chat soon!

  11. check these guys out

    I?m impressed, I must claim. Really hardly ever do I come across a blog site that?s both enlightening and also enjoyable, and also let me tell you, you have hit the nail on the head. Your concept is superior; the concern is something that inadequate people are talking smartly around. I am very delighted that I came across this in my search for something associating with this.

  12. click here for info

    After research a few of the post on your website currently, and also I truly like your way of blogging. I bookmarked it to my book mark web site checklist as well as will be inspecting back quickly. Pls look into my website as well as well as let me know what you believe.

  13. Related Site

    When I initially commented I clicked the -Alert me when brand-new comments are added- checkbox as well as currently each time a remark is added I obtain four emails with the same comment. Exists any way you can eliminate me from that solution? Thanks!

  14. read what he said

    When I originally commented I clicked the -Inform me when brand-new remarks are added- checkbox and now each time a comment is added I obtain four e-mails with the very same comment. Exists any way you can remove me from that service? Many thanks!

  15. Our site

    This is the appropriate blog for any person who wishes to learn about this topic. You understand so much its practically hard to suggest with you (not that I actually would want?HaHa). You most definitely placed a brand-new spin on a subject thats been blogged about for several years. Excellent stuff, just wonderful!

  16. this article

    Can I simply say what a relief to discover somebody that actually knows what theyre speaking about on the web. You certainly know just how to bring a problem to light and also make it essential. More people need to read this and also recognize this side of the tale. I cant think youre not much more popular due to the fact that you certainly have the present.

  17. best phone sex

    Hello very nice site!! Guy .. Excellent .. Amazing .. I will bookmark your web site and take the feeds additionally? I am glad to find a lot of helpful information right here in the post, we’d like work out more techniques in this regard, thanks for sharing. . . . . .

댓글 남기기

이메일은 공개되지 않습니다.