[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Den tomme mængde i SQL.



Jeg har en situation hvor jeg egentligt gerne vil have log til at lave
en SQL-query med "den tomme mængde". Altså:

select * from table where id in ();
Dette vil altid give mig et tomt resultat og det er også hvad jeg
ønsker. 

Ovenstående query er dog invalid i både MySQL og PostgreSQL men det gør
ikke at databasen ikke kan finde ud af at evaluere den tomme mængde, da

select * from table where id in (select id from table where id != id);

Virker fint. (og giver selvfølgeligt en tom mængde). 

Hvis man altid bare skrev SQL i SQL-prompten, så ville dette være en
åbenlys dum ting at gøre.. men situationen er at jeg igennem et stykke
kode samler et array af ID'er fra... dette array bruges til at
konstruere følgelende SQL med:

select * from table where id in (join(",",@ids));

Hvilket netop ikke giver mig det forventede tomme resultatsæt i
situationen hvor @ids er tomt, men virker fint i alle andre tilfælde. 

Jesper
-- 
./Jesper Krogh, sslug@sslug, Jabber ID: sslug@sslug



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2006-02-01, 02:01 CET [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *