SQL Query - Set column1 with values from column2 based on the value of column3 [closed] - sql

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to update column1 with values from column2 based the value of column3. This is what I have:
UPDATE Table
SET Column1=Column2
WHERE Column3='Value'
Is this possible?
EDIT I tried this, but I didn't get the results I wanted (as in, none of my rows changed). I didn't get any errors though.
UPDATE Figured out my error. Answer is below.

Ah, Okay. Now I see where I went wrong. The Value of Column3 has the same name as Column2, so I messed up the order. This is what worked:
UPDATE Table SET Column2=Column1 WHERE Column3='Value'

Related

Access 2010 SQL Update Query [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I need to update every row in one table, with the help with two subqueries...
UPDATE MyTable
SET MyTable.ColumnToUpdate =
((SELECT 10000 / DCount("ID","MyTable")) * DCount("ID","MyTable","ID<="& MyTable.ID))
But this doesn't work, access complanis about an error in the first subquery...
How can i do this?
Thanks
You don't need the SELECT statement in the first piece. Try this:
UPDATE MyTable
SET MyTable.ColumnToUpdate =
((10000 / DCount("ID","MyTable")) * DCount("ID","MyTable","ID<="& MyTable.ID))

finding the word like in a sql query [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a string like this:
i would like to go to office, and i would like to go to market
My question is: how many times the word like occurs in the string?
Please write a query.
You can use regexp_count:
SELECT REGEXP_COUNT('i like to go , and i would like market', 'like')
FROM DUAL;
The word "like" occurs twice in the string you posted.
The following is a query:
SELECT *
FROM SOME_TABLE
WHERE SOME_VALUE = SOME_OTHER_VALUE
Share and enjoy.

SQL server , Add data in multi value attribute [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a table Photos with attribute comments
i want to declare that comments take many values
and want to know how to insert a new value to it
You should probably have a column photo_id in your comments table. This would let you have a lot of comments for each photo.
The way you are saying it, it would let you have the same comment in different photos, but that looks less likely to be what you really want.
Something like this:
photos:
id primary key
comments
id primary_key
photo_id foreign_key referencing photos(id)

How to be a command in SQL using LIKE? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to select records where a field (varchar (45)) contains one and only one letter x and the field length is greater than 20
In MySQL you can do:
SELECT * FROM tablename WHERE fieldname REGEXP '^[x]{20,}$'

Search for all strings that have a space in between using SQL query [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Take for example I have entries like 'Jhon Abraham','Hrithik Roshan' and 'Jimmy'.
Then, the output should fetch me the first two entries i.e. 'Jhon Abraham' and 'Hrithik Roshan'.
SELECT columnName
FROM table
WHERE trim(columnName) LIKE '% %'
SELECT col_name FROM table_name WHERE col_name LIKE '% %';