phpbar.de logo

Mailinglisten-Archive

AW: Suche Hilfe bei entfernungsprob

AW: Suche Hilfe bei entfernungsprob

Wolfgang Hauck mysql-de_(at)_lists.bttr.org
Mon, 14 Oct 2002 16:12:02 +0200


Nachtrag zu Subselect:

MySQL Server currently only supports nested queries of the form INSERT ... 
SELECT ... and REPLACE ... SELECT .... You can, however, use the function 
IN() in other contexts. Subselects are currently being implemented in the 
4.1 development tree.
Meanwhile, you can often rewrite the query without a subselect:
SELECT * FROM table1 WHERE id IN (SELECT id FROM table2);
This can be rewritten as:
SELECT table1.* FROM table1,table2 WHERE table1.id=table2.id;
The queries:
SELECT * FROM table1 WHERE id NOT IN (SELECT id FROM table2);
SELECT * FROM table1 WHERE NOT EXISTS (SELECT id FROM table2
                                       WHERE table1.id=table2.id);
Can be rewritten as:
SELECT table1.* FROM table1 LEFT JOIN table2 ON table1.id=table2.id
                                       WHERE table2.id IS NULL;
For more complicated subqueries you can often create temporary tables to 
hold the subquery. In some cases, however, this option will not work. The 
most frequently encountered of these cases arises with DELETE statements, 
for which standard SQL does not support joins (except in subselects). For 
this situation there are two options available until subqueries are 
supported by MySQL Server.

Nachzulesen bei:

http://www.mysql.com/doc/en/ANSI_diff_Sub-selects.html

MFG Wolfgang

---
Infos zur Mailingliste, zur Teilnahme und zum An- und Abmelden unter
-->>  http://www.4t2.com/mysql 



php::bar PHP Wiki   -   Listenarchive