真是莫名其妙,忘了拷贝原来那条SQL语句了 执行一条子查询 嵌套查询 SQL语句,结果返回 #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 'select namee from param where namee = 'style' ) LIMIT 0, 30' at 这是ACCESS翻版:select * from aa where a in (select b from aa where a='a1') 大找资料: www.shengfang.org SELECT C.CUST_NBR, C.NAME 在select查询语句里可以嵌入select查询语句,称为嵌套查询。有些书上将内嵌的select语句称为子查询,子查询形成的结果又成为父查询的条件。 www.shengfang.org 查询是使用最多的SQL命令。查询数据库需要凭借结构、索引和字段类型等因素。大多数数据库含有一个优化器(optimizer),把用户的查 询语句转换成可选的形式,以提高查询效率。 Subqueries www.shengfang.org 我的版本就是4.1了~MySQL 4.1.13a-nt SELECT * #1242 - Subquery returns more than 1 row SELECT * SELECT namee 在帮助里面看到一个例子: Starting with MySQL 4.1, all subquery forms and operations that the SQL standard requires are supported, as well as a few features that are MySQL-specific. With MySQL versions prior to 4.1, it was necessary to work around or avoid the use of subqueries. In many cases, subqueries can successfully be rewritten using joins and other methods. See Section 13.2.8.11, “Rewriting Subqueries as Joins for Earlier MySQL Versions”. Here is an example of a subquery: SELECT * FROM t1 WHERE column1 = (SELECT column1 FROM t2); In this example, SELECT * FROM t1 ... is the outer query (or outer statement), and (SELECT column1 FROM t2) is the subquery. We say that the subquery is nested in the outer query, and in fact it's possible to nest subqueries within other subqueries, to a great depth. A subquery must always appear within parentheses. The main advantages of subqueries are: They allow queries that are structured so that it's possible to isolate each part of a statement. They provide alternative ways to perform operations that would otherwise require complex joins and unions. They are, in many people's opinion, readable. Indeed, it was the innovation of subqueries that gave people the original idea of calling the early SQL ``Structured Query Language.'' 字体:大 中 小 |
![]() | 永久地址 http://www.shengfang.org/blog/p/iwas7mysqlsubq.php |
![]() | 引用地址 http://www.shengfang.org/blog/tb.php?tb_id=1124857363 |
2005年8月24日12:22星期三 [Dev开发]






