+ 6

sql - update table question

Hello everyone, Merry Christmas! Someone still visiting the forum? Could you pls take a look at the following language? Where is the problem? 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;

25th Dec 2020, 5:37 PM
YANG Fei
YANG Fei - avatar
9 odpowiedzi
- 2
I think it is a simple typing error in the query. The table name is "leaderboard", but your query was trying to select from "learderboard". There is an extra 'r' in the table name used in the query.
25th Dec 2020, 5:46 PM
Brian
Brian - avatar
+ 3
Your Output name,country,population,attractiveplace Lisbon,Portugalia,504718,Belem Tower Madrid,Spain,3223000,Plaza Mayor Paris,France,2161000,Eiffel Tower Expected Output name,country,population,attractiveplace Lisbon,Portugalia,504718,Belem Tower Madrid,Spain,3223000,Plaza Mayor Paris,France,2161000,Eiffel Tower
25th Dec 2020, 5:40 PM
YANG Fei
YANG Fei - avatar
+ 3
30th Sep 2021, 11:03 AM
Oumaima Matelli
Oumaima Matelli - avatar
+ 1
Brian you save life!! I check several times and didn’t find this error😂😂
25th Dec 2020, 5:47 PM
YANG Fei
YANG Fei - avatar
+ 1
Glad I could help! :D
25th Dec 2020, 5:52 PM
Brian
Brian - avatar
+ 1
YANG Fei since you replaced the question with a new one, now the old answers do not match. It will confuse future readers. You should have started a new question. Answering your new question: The output data look correct. I think you are asking how to format the output to have double-spaced lines instead of single-spaced. Normally that is a feature of your IDE or report software. If you need it done as part of the query, then I can give you a hack that might work. Since the last field is a string type, then possibly you could concatenate to it (+) the literal constant ASCII characters 13 and 10, which are carriage return (CR) and line feed (LF) respectively. Use the CHR function in the SELECT statement to convert from their numeric value into the characters.
26th Dec 2020, 10:56 AM
Brian
Brian - avatar
0
@Brian I updated my question, can you help?
25th Dec 2020, 10:24 PM
YANG Fei
YANG Fei - avatar
0
I still don't get it!!
18th Mar 2023, 4:41 AM
Beka Fekadu
0
ALTER TABLE cities ADD AttractivePlace VARCHAR(255); UPDATE cities SET AttractivePlace = CASE WHEN name = 'Lisbon' THEN 'Belem Tower' WHEN name = 'Madrid' THEN 'Plaza Mayor' WHEN name = 'Paris' THEN 'Eiffel Tower' END; SELECT * FROM cities; check out this Query Its working
1st Oct 2023, 6:06 AM
Kuddana Dinesh
Kuddana Dinesh - avatar