![]() This would impact two rows and finally COMPANY table would have the following records − WHERE AGE IN (SELECT AGE FROM COMPANY_BKP Either single or multiple columns in a table can be updated when using a subquery with the UPDATE statement.Īssuming, we have COMPANY_BKP table available which is a backup of COMPANY table.įollowing example updates SALARY by 0.50 times in COMPANY table for all the customers, whose AGE is greater than or equal to 27. The subquery can be used in conjunction with the UPDATE statement. ![]() To copy the complete COMPANY table into COMPANY_BKP, following is the syntax − ![]() INSERT INTO table_name ) ]Ĭonsider a table COMPANY_BKP with similar structure as COMPANY table and can be created using the same CREATE TABLE using COMPANY_BKP as the table name. The selected data in the subquery can be modified with any of the character, date, or number functions.įollowing is the basic syntax is as follows − The INSERT statement uses the data returned from the subquery to insert into another table. Subqueries can also be used with INSERT statements. Subqueries can be used with the SELECT, INSERT, UPDATE, and DELETE statements along with the operators such as =,, >=, SELECT * A Subquery or Inner query or Nested query is a query within another SQLite query and embedded within the WHERE clause.Ī subquery is used to return data that will be used in the main query as a condition to further restrict the data to be retrieved. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |