update?

  • i had a tabel (movie) it has movieId,movieName,rate,Price

    i wanna set the price 12000*2 if the movie Name is 'fofo'

    else

    if the movieName is 'lili' price should be 25000/2

    how can i write this?can u help me?

  • Something like...

    update movie

    set price = case when movieName = 'fofo' then 12000*2 when movieName = 'lili' then 25000/2 end

    where movieName in ('fofo', 'lili')

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

  • but

    update movie

    set price = case when movieName = 'fofo' then 12000*2 when movieName = 'lili' then 25000/2 end

    where movieName in ('fofo', 'lili')

    doesn't work

  • you mean it isn't correct???

    create trigger trigger_price

    on Tbl_Flight

    for insert

    as

    if adult = 1

    begin

    insert into Tbl_Flight(price) values (1500000)

    return

    end

    else

    if child = 1

    begin

    insert into Tbl_Flight(price) values (1500000*0.5)

    return

    end

    else

    if infant= 1

    begin

    insert into Tbl_Flight(price) values (1500000*0.2)

    return

    end

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply