473,406 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Help with a quiry - update is whiping my existing data when it shouldent?

This is my general quiry

update `Antrix`.`creature_proto`
set `health` = (select `health` from `antrix2`.`creature_proto` where `entry` = (select entry from `Antrix`.`creature_proto`);

I have a dB named Antrix and one named antrix2
I want to overwrite the data in colums Antrix.creature_proto.(health) with the data from antrix2.creature_proto.(health)....

this works... but hte problem is.... where entries in Antrix.entry arent in antrix2.entry.. it sets the data from Antrix.health to 0 on those entries.

Any ideas how to stop this?
Jul 11 '07 #1
10 1723
....where entries in Antrix.entry arent in antrix2.entry.. it sets the data from Antrix.health to 0 on those entries.

Yes, It Will !

Try something like :

Expand|Select|Wrap|Line Numbers
  1. UPDATE dbo.Antrix.creature_proto
  2. SET health = dbo.Antrix2.creature_proto.health
  3. WHERE dbo.Antrix.creature_proto.entry = dbo.Antrix2.creature_proto.entry
  4.  
I haven't tested it, but I think it will put you on the right track.
Jul 11 '07 #2
UPDATE dbo.Antrix.creature_proto
SET health = dbo.antrix2.creature_proto.health
WHERE dbo.Antrix.creature_proto.entry = dbo.antrix2.creature_proto.entry and dbo.antrix2.creature_proto.health > 25 and dbo.antrix2.creature_proto.attacktime > 700 and dbo.antrix2.creature_proto.level > 1 and dbo.antrix2.creature_proto.mindamage > 1 and dbo.antrix2.creature_proto.maxdamage > 1;


this is my query now.

it says you have an error in syntax near dbo ect

i cant find a problem.
Jul 12 '07 #3
Does that mean you've sorted the problem out ?
Jul 12 '07 #4
My mistake.....the format should be : DatabaseName.DatabaseOwner.DatabaseTable

ie

Antrix.dbo.creature_proto
Antrix2.dbo.creature_proto

NOT

dbo.Antrix.creature_proto
dbo.Antrix2.creature_proto
Jul 12 '07 #5
still getting this error

ERROR 1064 : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.creature_proto
SET health = antrix2.dbo.creature_proto.health
WHERE Antrix' at line 1
Jul 12 '07 #6
Infide
28
This is my general quiry

update `Antrix`.`creature_proto`
set `health` = (select `health` from `antrix2`.`creature_proto` where `entry` = (select entry from `Antrix`.`creature_proto`);

I have a dB named Antrix and one named antrix2
I want to overwrite the data in colums Antrix.creature_proto.(health) with the data from antrix2.creature_proto.(health)....

this works... but hte problem is.... where entries in Antrix.entry arent in antrix2.entry.. it sets the data from Antrix.health to 0 on those entries.

Any ideas how to stop this?
Expand|Select|Wrap|Line Numbers
  1. Update Creature_proto
  2. set 'health' = cp2.Health
  3. from antrix2.Creature_proto cp2
  4.    inner join antrix.creature_proto cp1
  5.         on cp1.entry = cp2.entry
  6.  
Jul 12 '07 #7
1064 : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''health' = cp2.Health
from antrix2.Creature_proto cp2
inner join Antrix.creatu' at line 2


still getting errors
thanks for trying
Jul 12 '07 #8
Infide
28
1064 : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''health' = cp2.Health
from antrix2.Creature_proto cp2
inner join Antrix.creatu' at line 2


still getting errors
thanks for trying
Expand|Select|Wrap|Line Numbers
  1. Update antrix.Creature_proto
  2. set health = cp2.Health
  3. from antrix2.Creature_proto cp2
  4.    inner join antrix.creature_proto cp1
  5.         on cp1.entry = cp2.entry
  6.  
Jul 12 '07 #9
no luck
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''health' = cp2.Health
from antrix2.Creature_proto cp2
inner join Antrix.creatu' at line 2
Jul 13 '07 #10
it seems that my original query works just that it dosent consider the where clause in the Select from bit..


update `Antrix`.`creature_proto` set `health` = (select `health` from `antrix2`.`creature_proto` where antrix2.creature_proto.level > 1 and antrix2.creature_proto.maxdamage > 1 and antrix2.creature_proto.mindamage > 1 and antrix2.creature_proto.health > 25 and antrix2.creature_proto.attacktime > 600 and antrix2.creature_proto.`entry` = `Antrix`.`creature_proto`.`entry`);

None of the where clauses worked ... all were changed regardless of what was said in Where.
Jul 13 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Google Mike | last post by:
I have one table of new records (tableA) that may already exist in tableB. I want to insert these records into tableB with insert if they don't already exist, or update any existing ones with new...
21
by: Dan | last post by:
Hi, just ran into my first instance of a backend Access97 database not compacting. I'm getting the "MSACCESS.EXE has generated errors.." message on compact. I've narrowed it down to the largest...
4
by: MikeY | last post by:
Hi everyone, I have posted earlier this week, but I'm still scratching my head trying to figure out how to change/modify my data back to my db. Using C# Windows forms. I am trying to learn how...
4
by: Jm | last post by:
I'm trying to set up ASP.NET on my Windows 2000 server w/ IIS 5 and MS ISA Server. Here's what I have done so far without any luck. Here's the results from the pages I've created...
2
by: Calvin KD | last post by:
Hi everyone, I know the solution to my problem is probably very simple but I just can't seem to figure out how to do it. My problem is, I have an XML file as a datastore, I read it into a dataset...
2
by: Anantha | last post by:
Dear All, One day our Windows 2000 Server OS crashed, so our NT admin has re-installed the OS on C: drive. Fortunately we kept our database file and installation in F: drive. When we...
1
by: anjangoswami06 | last post by:
Hi, I am interested to know how it is possible to update the data type with "insert" with stl hash_map. Suppose we have, hash_map<const char *, MyDataType, hash_compare<const char*,...
1
by: dasilva109 | last post by:
Hi guys I am new to C++ and need urgent help with this part of my code for a uni coursework I have to submit by Thursday //ClientData.h #ifndef CLIENTDATA_H #define CLIENTDATA_H #include...
2
by: dasilva109 | last post by:
Hi guys I am new to C++ and need urgent help with this part of my code for a uni coursework I have to submit by Thursday //ClientData.h #ifndef CLIENTDATA_H #define CLIENTDATA_H #include...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.