If I have a table T with 4 rows & 2 columns A & B. A has
values 1,2,3,4. and B has 10,20,30,40. Write an Update SQL
query which can Swap the values of A & B for all records.
(Do not use a sub-query)
Answers were Sorted based on User's Feedback
Answer / bunty
UPDATE T
SET A = B,B=A;
I am surprized but above query will fetch the desired
result.
Cheers,
Bunty
Is This Answer Correct ? | 30 Yes | 1 No |
Answer / lova raju allumalla
update T set A=B,B=A where A in (select A from T);
Is This Answer Correct ? | 1 Yes | 2 No |
Explain what is a subquery ?
how to rename an existing table in mysql? : Sql dba
What is the use of a view in sql?
how to remove records from table? no name 1 a 2 b 1 a 2 b 3 c
What is nosql db?
Does truncate release storage space?
Can we rollback delete command?
Hi All, I am new to both this blog and technology. I was able to see a response for one of the questions on triggers as below. I would like to know why are we using " if rtrim(to_char(sysdate,'day'))=rtrim('sunday') then" instead, can't we use " if sysdate = 'sunday' then". I can understand the use of "rtrim", but dont know y v r using to_char. I have seen this in many cases but did not get a convincible explaination. Please help me with this and do excuse if this question sounds silly. Thanks in advance...... create or replace trigger trg_sun before insert on <table name> begin if rtrim(to_char(sysdate,'day'))=rtrim('sunday') then raise_application_error(-20345,'no transaction in sunday'); end if; end trg_sun;
Does sap use sql?
How to get list of all tables from a database?
what are ddl statements in mysql? : Sql dba
Why is theta join required?