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 = '[email protected]') ;

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
  • 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...

  • 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...

  • 1. This trigger is from Figure 16.2 of the text. Copy and run this trigger so it is created in th...

    1. This trigger is from Figure 16.2 of the text. Copy and run this trigger so it is created in the ap database. You can run the UPDATE below to test it. Notice two things. The error message appears as a pink screen just like a syntax error would. Also, if you then query the invoices table, the UPDATE statement did not execute. The trigger prevented the erroneous UPDATE from changing the data.                 DELIMITER // CREATE TRIGGER invoices_before_update    BEFORE UPDATE...

  • Step 1: Create table audits via triggers The system must log any insertion, deletion, or updates...

    Step 1: Create table audits via triggers The system must log any insertion, deletion, or updates to the following tables: • Employee table (project 1) create table Employee ( empNumber char(8) not null, firstName varchar(25) null, lastName varchar(25) null, ssn char(9) null, address varchar(50) null, state char(2) null, zip char(5) null, jobCode char(4) null, dateOfBirth date null, certification bit null, salary money null, constraint PK_EMP PRIMARY KEY(empNumber), constraint EMP_STATECHECK CHECK(state in ('CA','FL')) ) GO • Job table (project 1) create...

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
ADVERTISEMENT