Zdravim, netušíte jestli MySQL, které tu běží podporuje vnořené dotazy?
Nefunguje mi dotaz:
SELECT cislo FROM Cela WHERE cislo NOT IN (SELECT Uvez1_cislo FROM Vysetrovany);
ma to umet vybrat cisla cel, ktera nema uveden zadny vysetrovany v jine tabulce...
Diky.
Odpovím si sám,
chytrý manual řekl:
For MySQL versions prior to 4.1, most subqueries can be successfully rewritten using joins and and other methods. See section 6.4.2.11 Rewriting Subqueries for Earlier MySQL Versions.
-->
It is often possible to rewrite a query without a subquery:
SELECT * FROM t1 WHERE id IN (SELECT id FROM t2);
This can be rewritten as:
SELECT t1.* FROM t1,t2 WHERE t1.id=t2.id;
The queries:
SELECT * FROM t1 WHERE id NOT IN (SELECT id FROM t2);
SELECT * FROM t1 WHERE NOT EXISTS (SELECT id FROM t2 WHERE t1.id=t2.id);
Can be rewritten as:
SELECT table1.* FROM table1 LEFT JOIN table2 ON table1.id=table2.id
WHERE table2.id IS NULL;
---------------
Takze dotaz zhora mi facha v tyhle podobe:
SELECT cislo FROM Cela c LEFT JOIN Vysetrovany v ON c.cislo = v.uvez1_cislo WHERE v.uvez1_cislo IS NULL
je to divny, co...
nebolo by jednoduchsie upgrade na MySQL ver 4.1 ?
lebo ja by som tiez potreboval vnorene selecty pouzit :(((