bazinga
bazinga

Reputation: 2250

How to write a conditional sql query?

I have a table called student like:

name age roll_no



X    Y

I want to write a sql query such that if name='X' and age='Y' then insert 'Z' to roll_no. How can I do that?

Upvotes: 0

Views: 26

Answers (1)

Abhik Chakraborty
Abhik Chakraborty

Reputation: 44844

That's not insert rather update.

update table_name set roll_no = 'Z' where name='X' and age='Y'

Upvotes: 1

Related Questions