[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
 

Re: [PROGRAMMERING] [SQL] Betinget INSERT?



On Wed, Mar 25, 2009 at 10:58:11AM +0100, Jacob Sparre Andersen wrote:
> Har SQL en kompakt og effektiv formulering af at man gerne vil
> indsætte en række i en tabel, hvis der ikke allerede findes en række
> med samme nøgle?

Om jag förstår din fråga rätt så kan man göra någonting i stil med:

insert into THE_TABLE(THE_KEY, ...) SELECT(value_to_insert, ...)
   FROM THE_TABLE
  WHERE THE_TABLE.THE_KEY NOT IN
      (
        SELECT THE_TABLE.THE_KEY
          FROM THE_TABLE
         WHERE THE_KEY = value_to_insert);


hälsningar
Håkan


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2009-04-01, 02:01 CEST [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] *