Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,994
    Thanks
    120
    Thanked 76 Times in 76 Posts

    case/insert/don't insert if does not match ...

    Code:
    insert into t  (a)
    select 
    (case b when 'D' then 'foo'
               when 'E' then 'foo1'
               end)         
    from t1
    This inserts foo and foo1, but when there is something else then "E" or "D" in source table it inserts null i.e. empty string. How to not insert at all in case of not "E" and not "D" ?
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • #2
    New Coder
    Join Date
    Mar 2006
    Location
    Chennai India
    Posts
    34
    Thanks
    0
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by BubikolRamios View Post
    This inserts foo and foo1, but when there is something else then "E" or "D" in source table it inserts null i.e. empty string. How to not insert at all in case of not "E" and not "D" ?
    This might be what you are looking for (http://forums.devshed.com/mysql-help...rt-439435.html)
    Chris, Developer, Chrisranjana.com
    Ruby on Rails Programmers,
    Php laravel developers,
    http://www.chrisranjana.com


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •