The AND in your UPDATE clause makes this a logical operator instead
of being a SQL keyword.

Your syntax is wrong:

UPDATE ...
SET mycol = value,
mycol2 = value
[WHERE ... ]

With regards,

Martijn Tonies
Upscene Productions
http://www.upscene.com

Download Database Workbench for Oracle, MS SQL Server, Sybase SQL
Anywhere, MySQL, InterBase, NexusDB and Firebird!

-----Original Message----- From: Surya Savarika Sent: Wednesday, July 09, 2014 3:56 PM To: mysql@lists.mysql.com Subject: Cannot Update, at least not how I'm telling it to!
Hi.

mysql> describe unions_data;
+-------------+-------------+------+-----+---------+----------------+
| Field       | Type        | Null | Key | Default | Extra          |
+-------------+-------------+------+-----+---------+----------------+
| ID          | int(11)     | NO   | PRI | NULL    | auto_increment |
| Title       | varchar(70) | NO   |     | NULL    |                |
| Description | text        | YES  |     | NULL    |                |
| UsersID     | int(11)     | NO   | MUL | NULL    |                |
+-------------+-------------+------+-----+---------+----------------+
4 rows in set (0.02 sec)

mysql> select * from unions_data;
+----+-----------+-------------+---------+
| ID | Title     | Description | UsersID |
+----+-----------+-------------+---------+
|  4 | Union One | descr one   |       2 |
|  5 | Union Two | descr two   |       2 |
+----+-----------+-------------+---------+
2 rows in set (0.00 sec)

mysql> update unions_data set Title='Dos' and Description='dos' where ID=5;
ERROR 1292 (22007): Truncated incorrect DOUBLE value: 'Dos'
mysql> update unions_data set Title=2.2 and Description='dos' where ID=5;
Query OK, 1 row affected (0.33 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from unions_data;
+----+-----------+-------------+---------+
| ID | Title     | Description | UsersID |
+----+-----------+-------------+---------+
|  4 | Union One | descr one   |       2 |
|  5 | 0         | descr two   |       2 |
+----+-----------+-------------+---------+
2 rows in set (0.00 sec)

Notice that it threw an error about an incorrect DOUBLE value for a
field that is a varchar. Notice that when it did decide to update, it
updated incorrectly and it updated Title but _not_ Description, yet
issued no Warnings. Am I missing something??
TIA,
Savi

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql

Reply via email to