Question

How do I set a column attribute with value from another table? I have this manager_specialisation table: CREATE TABLE ma...

How do I set a column attribute with value from another table?

I have this manager_specialisation table:

CREATE TABLE manager_specialisation (
specialisation_id NUMBER(4) NOT NULL,
specialisation_type VARCHAR(50) NOT NULL
);

And I want to update a column in my garage_manager table like this except the specialisation_id is WHERE specialisation_type = 'S'.?

UPDATE garage_manager
SET specialisation_id=manager_specialisation.specialisation_id
WHERE man_id=1 AND garage_email= (SELECT garage_code
FROM garage
WHERE garage_email = 'melbournec@rdbms.example.com') ;

0 0
Add a comment Improve this question Transcribed image text
Answer #1

As you want copy a column from on one table to another table the below query will update the garage_manager table with specialisation_id where specialisation_type='S' by using this nested query.

The nested query selects the specialisation_id from manager_specialisation with the condition specialisation_type='S'.

The table garage_manager is taken as gm as object.

Hope you understood.

QUERY:

UPDATE garage_manager gm

SET specialisation_id=manager_specialisation.specialisation_id

WHERE gm.specialisation_id=(SELECT specialisation_id form manager_specialisation WHERE  specialisation_type='S' );

Add a comment
Know the answer?
Add Answer to:
How do I set a column attribute with value from another table? I have this manager_specialisation table: CREATE TABLE ma...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • How do I combine these two SELECT query into one INSERT?Selecting a value from different tables...

    How do I combine these two SELECT query into one INSERT?Selecting a value from different tables in ORACLE? I inserted a row into vehicle_unit by using INSERT this way: INSERT INTO vehicle_unit(vunit_id,vunit_purchase_price,vunit_exhibition_flag,vehicle_insurance_id,vunit_rego, garage_code) SELECT '3',50000.00, 'R', 'sports-ute-449-12b ', 'RD3000', garage_code FROM garage WHERE garage_email ='melbournec@rdbms.example.com '; BUT now I do not want to manually enter sports-ute-449-12b. I want to select it from vehicle_detail table using the vehicle_title like this: SELECT vehicle_insurance_id FROM vehicle_detail WHERE vehicle_title= 'Toyota Hilux SR Manual 4x2...

  • In SQL, how do I put one column from one table right next to another column...

    In SQL, how do I put one column from one table right next to another column from a different table?

  • Hello, Does anyone have any input on how to fragment this table in visual studio? CREATE...

    Hello, Does anyone have any input on how to fragment this table in visual studio? CREATE TABLE [dbo].[Stock] ( [itemNo] INT NOT NULL , [store] VARCHAR(50) NOT NULL, [qtyOnHand] INT NULL, [qtyHand] INT NULL, [qtyOnOrder] INT NULL, [reorderPoint] INT NULL, CONSTRAINT [FK_Stock_Item] FOREIGN KEY ([itemNo]) REFERENCES [Item]([itemNo]), CONSTRAINT [FK_Stock_Store] FOREIGN KEY ([store]) REFERENCES [Store]([storeName]), CONSTRAINT [PK_Stock] PRIMARY KEY ([itemNo], [store]), The other tables are: CREATE TABLE [dbo].[Item] ( [itemNo] INT NOT NULL PRIMARY KEY, [itemName] VARCHAR(50) NULL, [supplier] VARCHAR(50) NULL,...

  • Please Explain why I am getting this error from the code below. ORA-06550: line 1, column...

    Please Explain why I am getting this error from the code below. ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'P_PRODUCT_INFORMATION' I have tried changing everything. Code is below. Table to use: CREATE TABLE ProductTable(     ProductID INTEGER NOT NULL primary key,     ProductName VARCHAR(50) NOT NULL,     ListPrice NUMBER(10,2),     Category INTEGER NOT NULL ); / INSERT INTO ProductTable VALUES(299,'Chest',99.99,10); INSERT INTO ProductTable VALUES(300,'Wave Cruiser',49.99,11); INSERT INTO ProductTable VALUES(301,'Megaland Play Tent',59.99,11); INSERT...

  • Database Management 6. [5] Create the following table: CREATE TABLE customer ( cust_name VARCHAR(30) NOT NULL,...

    Database Management 6. [5] Create the following table: CREATE TABLE customer ( cust_name VARCHAR(30) NOT NULL, address VARCHAR(60), UNIQUE (cust name, address)); A. Run the following inserts and explain why both work and how will you prevent it INSERT INTO customer VALUES ('Alex Doe', NULL); INSERT INTO customer VALUES ('Alex Doe', NULL); 7. [5] Modify the following table definition to ensure that all employees have a minimum wage of $10 CREATE TABLE employee ( empId INT PRIMARY KEY, empName VARCHAR(40)...

  • SQL Query Question: I have a database with the tables below, data has also been aded...

    SQL Query Question: I have a database with the tables below, data has also been aded into these tables, I have 2 tasks: 1. Add a column to a relational table POSITIONS to store information about the total number of skills needed by each advertised position. A name of the column is up to you. Assume that no more than 9 skills are needed for each position. Next, use a single UPDATE statement to set the values in the new...

  • -- Schema definition create table Customer (     cid   smallint not null,     name varchar(20),    ...

    -- Schema definition create table Customer (     cid   smallint not null,     name varchar(20),     city varchar(15),     constraint customer_pk         primary key (cid) ); create table Club (     club varchar(15) not null,     desc varchar(50),     constraint club_pk         primary key (club) ); create table Member (     club varchar(15) not null,     cid   smallint     not null,     constraint member_pk         primary key (club, cid),     constraint mem_fk_club         foreign key (club) references Club,     constraint mem_fk_cust...

  • CREATE TABLE actor( id INTEGER NOT NULL, name VARCHAR(100), PRIMARY KEY (id) ); SELECT name FROM...

    CREATE TABLE actor( id INTEGER NOT NULL, name VARCHAR(100), PRIMARY KEY (id) ); SELECT name FROM actor WHERE name LIKE 'M%'; Q. How to run explain plan on the above query and display its output?

  • Using SQL and the following info Question 3: Find the people who do not have Viper...

    Using SQL and the following info Question 3: Find the people who do not have Viper Certification but are still assigned to Viper class ship Find the fname, lname, and ship_instance_id for all people who do not have Viper certification but are assigned to at least one instance of a Viper class ship (this includes all variants of Viper class ships). Return a row for every ship/person combination. Order your results by fname in ascending order. Use the BSG database...

  • Using SQL and the following info Question 3: Find the people who do not have Viper...

    Using SQL and the following info Question 3: Find the people who do not have Viper Certification but are still assigned to Viper class ship Find the fname, lname, and ship_instance_id for all people who do not have Viper certification but are assigned to at least one instance of a Viper class ship (this includes all variants of Viper class ships). Return a row for every ship/person combination. Order your results by fname in ascending order. Use the BSG database...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT