Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
What Happens If the UPDATE Subquery Returns Multiple Rows
What Happens If the UPDATE Subquery Returns Multiple Rows? - MySQL FAQs - Understanding SQL INSERT, UPDATE and DELETE Statements
✍: FYIcenter.com
If a subquery is used in a UPDATE statement, it must return exactly one row for each row in the update table that matches the WHERE clause. If it returns multiple rows, MySQL server will give you an error message. To test this out, you can try the following tutorial exercise:
mysql> INSERT INTO fyi_rates VALUES (0, 'Number 1'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO fyi_rates VALUES (0, 'Number 2'); Query OK, 1 row affected (0.00 sec) mysql> SELECT * FROM fyi_rates WHERE id = 0; +------+----------+ | id | comment | +------+----------+ | 0 | Number 1 | | 0 | Number 2 | +------+----------+ 2 rows in set (0.00 sec) mysql> UPDATE fyi_links SET notes = ( SELECT comment FROM fyi_rates WHERE fyi_rates.id = fyi_links.id ) WHERE id = 0; ERROR 1242 (21000): Subquery returns more than 1 row
2007-05-11, 4995👍, 0💬
Popular Posts:
.NET INTERVIEW QUESTIONS - Is versioning applicable to private assemblies? Versioning concept is onl...
What Happens If a Hyper Link Points to a Music File? - XHTML 1.0 Tutorials - Understanding Hyper Lin...
Can event’s have access modifiers ? Event’s are always public as they are meant to serve every one r...
What will be printed as the result of the operation below: main() { char *p1; char *p2; p1=(char *)m...
How can I show HTML examples without them being interpreted as part of my document? Within the HTML ...