Is there a faster way to add new column data with hundreds of rows? [closed] - sql

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 11 months ago.
Improve this question
I have a decent-sized table 'countries' with about 10 columns. I recently added a new column to the table 'GDP' and I am entering the information per row using
UPDATE countries
SET GDP=(value)
WHERE name = (country);
I have 200 countries in this table. Is there a better way to update this information?
This project is from Khan Academy. We are asked to select a database and run queries on it. The data was pulled from https://gist.github.com/pamelafox/ad4f6abbaac0a48aa781
I am just making sure that there isn't a more efficient way of adding this information to the existing table 'countries' where the primary key is the name of the country.

Related

How does one query a database? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
Improve this question
How does one get the first name info from a Users table, which has a first name column?
First of all welcome to the community. I suggest you read the guidelines on how to properly ask a question here and you might want to write a title that is relevant to your question.
Now to the question:
Assuming tblUsers is a table in your database and 'first_name' is a column in your table, you can use SELECT followed by the column you want to select.
Lastly, add FROM to select which table you want to select from.
So in your case it would be:
SELECT first_name FROM tblUsers;
You can read more about SELECT here

SQL how to find number of unique id's [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
enter image description here
enter image description here
Hi, I was wondering how I will find the number of unique (different) customers found in the list above. I have shown the code I have written up but not sure how to get unique Customer ID count as you can see there are many duplicate customerID's because each customer can match with many products.
You can use count(distinct):
select count(distinct customer_id)
from t;

In Oracle SQL, how do I find where a column may be referenced using just queries? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have a specific column, called DELIVER_TO_LOCATION_ID , which is in a table called apps.po_requisition_lines_all
I need to dig into the database and derive the continent from the DELIVER_TO_LOCATION_ID ,
In SQL Developer I can't seem to find a way to do this .
any tips appreciated. thanks
You can use following command-
desc tableName
It'll give you description of table including every column in it having any constraints on it or not like primary key, reference key etc.

SQL Server 2008 Replace substring [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a Screen table which has name and display_name columns. I am trying to replace the word Lawfirm with Law Firm in name and display_name columns for all the records of Screen table.
My SQL experience is pretty premature, I am wondering is there a way to achieve this using a SQL script?
Yes, you can do this:
update screen
set display_name = replace(display_name, 'Lawfirm', 'Law Firm')
where display_name like '%Lawfirm%';

like query for searching a multiple word in table column in sql [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have table named 'categories' and it has one column name 'catvalues' with values see example below:
catvalues
------------------------
Party wear,Plain,Classic
Party wear,Plain
Party wear,Classic
now i want like query which when i search for 'Party wear,Classic' it should return 2 rows like below:
catvalues
---------------------------
Party wear,Plain,Classic
Party wear,Classic
maybe something like...
SELECT * FROM table
WHERE catvalues LIKE '%Party wear%Classic%'
but i really need more info about your questions
This sounds like your trying to put to much information into one column.