+ 1
Sql favourate place problem? Help me to solve this?! And correct my code
ALTER TABLE cities ADD AttractivePlace UPDATE cities SET AttractivePlace = 'Belem Tower' WHERE name='Lisbon' UPDATE cities SET AttractivePlace = 'Plaza Mayor' WHERE name='Madrid' UPDATE cities SET AttractivePlace = 'Eiffel Tower' WHERE name='Paris' SELECT * FROM cities;
13 Antworten
+ 9
ALTER TABLE cities add AttractivePlace VARCHAR;
UPDATE cities
SET AttractivePlace = 'Belem Tower'
WHERE name = 'Lisbon';
UPDATE cities
SET AttractivePlace = 'Plaza Mayor'
WHERE name = 'Madrid';
UPDATE cities
SET AttractivePlace = 'Eiffel Tower'
WHERE population = 2161000;
SELECT * FROM cities;
As above I have tried with different column to set it in capital as mentioned in task. But it isn't happened. Could someone please bother to intervene with the proper resolution plz.
+ 4
ALTER TABLE cities add AttractivePlace VARCHAR;
UPDATE cities
SET AttractivePlace = 'Belem Tower'
WHERE name = 'Lisbon';
UPDATE cities
SET AttractivePlace = 'Plaza Mayor'
WHERE name = 'Madrid';
UPDATE cities
SET AttractivePlace = 'Eiffel Tower'
WHERE population = 2161000;
SELECT * FROM cities;
+ 3
ALTER TABLE cities
ADD place varchar(20);
update cities
SET Place = 'Belem Tower'
WHERE name='Lisbon';
update cities
SET Place = 'Plaza Mayor'
WHERE name='Madrid';
update cities
SET Place = 'Eiffel Tower'
WHERE name='Paris';
SELECT * FROM cities;
+ 2
ALTER TABLE cities
ADD AttractivePlace VARCHAR;
UPDATE cities SET AttractivePlace = 'Belem Tower'
WHERE name = 'Lisbon';
UPDATE cities SET AttractivePlace = 'Plaza Mayor'
WHERE name = 'Madrid';
UPDATE cities SET AttractivePlace = 'Eiffel Tower'
WHERE name = 'Paris';
SELECT * FROM cities
+ 2
Aa sorry about that . When we add new column and by using ALTER
Let’s say we have need update all row
Do we have to put UPDATE,SET,WHERE keyword for every row ?
+ 1
ALTER TABLE cities
ADD AttractivePlace
varchar (128);
UPDATE cities
SET AttractivePlace = 'Belem Tower'
WHERE name='Lisbon';
UPDATE cities
SET AttractivePlace = 'Plaza Mayor'
WHERE name='Madrid';
UPDATE cities
SET AttractivePlace = 'Eiffel Tower'
WHERE name='Paris';
SELECT * FROM cities;
+ 1
ALTER TABLE cities add Place VARCHAR;
UPDATE cities
SET Place = 'Belem Tower'
WHERE name = 'Lisbon';
UPDATE cities
SET Place = 'Plaza Mayor'
WHERE name = 'Madrid';
UPDATE cities
SET Place = 'Eiffel Tower'
WHERE population = 2161000;
SELECT * FROM cities;
This is the solution to
that problem,
Have a nice day.
0
Let me try anyway thanq
0
is there any way update multiple value without recurring update,where,set command ? just curioisity :)
0
Please elaborate the question once! Uğur Göktaş
0
Select *All and say "Hello"
I would like to know if this exercice is incorrect because when we copy the solution it's still wrong
I copied the answer of @Swapnil and it worked so could you tell me more about it please ?
Thanks*
0
I made a more effective way, in my case AttractivePlace is just place
ALTER TABLE cities
ADD place VARCHAR(128);
UPDATE cities
SET place =
CASE
WHEN name = 'Lisbon' THEN 'Belem Tower'
WHEN name = 'Madrid' THEN 'Plaza Mayor'
WHEN name = 'Paris' THEN 'Eiffel Tower'
END
;
SELECT * FROM cities;
0
Here is the correct answer
-- Add the new column to the table
ALTER TABLE cities
ADD COLUMN AttractivePlace VARCHAR(255);
-- Update the new column with specific values for certain cities
UPDATE cities
SET AttractivePlace = 'Belem Tower'
WHERE name = 'Lisbon';
UPDATE cities
SET AttractivePlace= 'Plaza Mayor'
WHERE name = 'Madrid';
UPDATE cities
SET AttractivePlace= 'Eiffel Tower'
WHERE name = 'Paris';
-- Select all records from the table to view the changes
SELECT * FROM cities;