Solved query data shift or move from clolumn to other (1 Viewer)

mhakim

Member
Local time
Today, 18:48
Joined
Jan 25, 2021
Messages
72
hi dears

good day

i am asking if i can


if there is null on column (name_english) then the yellow data move from (Chart_Name_English) column to the Null column

please look at PIC attached
 

Attachments

  • move data in query.PNG
    move data in query.PNG
    50.4 KB · Views: 204

June7

AWF VIP
Local time
Today, 07:48
Joined
Mar 9, 2014
Messages
5,468
Run an UPDATE action SQL

UPDATE tablename SET name_english = Chart_Name_English WHERE name_english IS NULL;

The data will be in both fields. Instead of actually copying the data, could just calculate this in a query (or textbox) when needed.

SELECT tablename.*, Nz(name_english, Chart_Name_English) AS EngName FROM tablename;
 
Last edited:

mhakim

Member
Local time
Today, 18:48
Joined
Jan 25, 2021
Messages
72
Run an UPDATE action SQL

UPDATE tablename SET name_english = Chart_Name_English WHERE name_english IS NULL;

The data will be in both fields. Instead of actually copy the data, could just calculate this in a query (or textbox) when needed.

SELECT tablename.*, Nz(name_english, Chart_Name_English) AS EngName FROM tablename;

where i can run this query

it give me message

operation must use updateble query

how can i use updateble query

i already have normal union select query as PIC

how do i run this SQL Statement to affect the query by new data
 

oleronesoftwares

Passionate Learner
Local time
Today, 08:48
Joined
Sep 22, 2014
Messages
1,159
how do i run this SQL Statement to affect the query by new data
Create a new query by clicking query design tab
click on SQL View at the top left
enter the update query @June7 sent you, but change the table name to your own table name
save it.

The query will appear on the database window
you can then click it to run it.
 

June7

AWF VIP
Local time
Today, 07:48
Joined
Mar 9, 2014
Messages
5,468
What do you mean by "PIC"?
What exactly is the SQL statement you built?
Why is a UNION query involved? A UNION query is not an updateable dataset.
What are you really trying to accomplish?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:48
Joined
Oct 29, 2018
Messages
21,467
hi dears

good day

i am asking if i can


if there is null on column (name_english) then the yellow data move from (Chart_Name_English) column to the Null column

please look at PIC attached
For your name_english column, you could try this.
Code:
NameEnglish: Nz([name_english], [chart_name_english])
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 11:48
Joined
Feb 19, 2002
Messages
43,257
1. As the others have mentioned, you should not store the same data in two places, especially in the same table. There are better methods.
2. If the field is text, it might contain ZLS rather then null since MS "helpfully" defaults the AllowZLS property to Yes rather than No. I recommend changing this default everytime you create a new text column. If you want code, I have a procedure that will fix all the tables in your database at once BUT, it will NOT fix existing records. You would need to run an update query to remove the ZLS value.
3. Fixing existing rows does not solve the problem. You also need to PREVENT future null values AND you won't be able to do that without changing the AllowZLS from Yes to No.
4. As your error message indicates, you can't update a union query.
 

Users who are viewing this thread

Top Bottom