Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Aphorismen
Applications
Business Economics & Admin.
My Computers
Cooking
Devices
Folders
Food
Hardware
Infos
Software Development
Sports
Operation Instructions
Todos
Test
Help
Glossary
Community portal
adaptions
Sidebar anpassen
Wiki RB4
Search
Search
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
SQL
(section)
Page
Discussion
English
Read
Edit
View history
Toolbox
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Selektion=== {| border=1 cellpadding=2 cellspacing=0 |- |<Selection> |:= |'''SELECT '''['''DISTINCT''']''' '''[<SpaltenExpressions> ]\\'''FROM''' <Tabellenliste> \\['''WHERE''' <PrĂ€dikat>] \\['''GROUP BY''' <Bedingung>] \\['''HAVING''' <Bedingung>] \\['''ORDER''' '''BY''' <Sortierfelder> [('''ASC'''{{{ |}}}'''DESC''')]] |- |<SpaltenExpressions>> |:= |'''COUNT ('''<Spalte>''')''' {{{ |}}} \\<Spalte> <MathematicalExpression> {{{ |}}} \\<Spalte> ['''AS''' <Alias>] {,<SpaltenExpression>} |- |<Spalte> |:= |'''* '''{{{ |}}} ''' '''[<Tabellenname>'''.'''] <Spaltenname> |- |<Tabellenliste> |:= |<Tabellenname> ['''AS''' <Alias>] {''',''' <Tabellenname> ['''AS''' <Alias>]} |} SQL wertet diese Klauseln in der Reihenfolge '''FROM''', '''WHERE''', '''GROUP''' '''BY''', '''HAVING''' und schlieĂlich '''SELECT''' aus. '''ORDER BY''' wird nach '''SELECT''' ausgefĂŒhrt d.h. in funktionaler Notation ausgedrĂŒckt '''ORDER BY(SELECT(HAVING(GROUP BY(WHERE(FROM'''...''')))))'''. EnthĂ€lt die <Tabellenliste> mehr als eine Tabelle, wird das kartesische Produkt gebildet, d.h. jede Zeile der einen Tabelle mit der Zeile der anderen Tabelle kombiniert, d.h. bei n Zeilen in Tabelle 1 und m Zeilen in Tabelle 2 die resultierende virtuelle Tabelle n*m Zeilen enthĂ€lt. '''DISTINCT''' verhindert doppelte EintrĂ€ge. Es wirkt auf alle angegebenen Spalten. Aliasing mit '''AS''' eignet sich um Mehrdeutigkeiten zu vermeiden, oder wenn man beispielsweise zu Testzwecken die Abfrage auf eine andere Tabelle ausfĂŒhren möchte. Im Rest der Selektion wird nur noch der <Alias> verwendet. MS Access: Die Syntax fĂŒr das Erzeugen einer Tabelle aus einer Selektion lautet '''SELECT''' <SpaltenExpression> '''INTO''' <TabellenName> '''FROM''' ... ====WHERE PrĂ€dikat==== {| border=1 cellpadding=2 cellspacing=0 |- |<PrĂ€dikat> |:= |<VergleichsprĂ€dikat> {{{ |}}} <LIKEPrĂ€dikat> {{{ |}}} <INPrĂ€dikat> {{{ |}}} <NOTINPrĂ€dikat> {{{ |}}} <BEETWEENPrĂ€dikat> {{{ |}}} <NULLPrĂ€dikat> {{{ |}}} <ALLPrĂ€dikat> {{{ |}}} <SOMEPrĂ€dikat> {{{ |}}} <ANYPrĂ€dikat> {{{ |}}} <EXISTSPrĂ€dikat> {{{ |}}} <UNIQUEPrĂ€dikat> {{{ |}}} <OVERLAPSPrĂ€dikat> {{{ |}}} <MATCHPrĂ€dikat> {{{ |}}} <ISPrĂ€dikat> { <LogicalOperator> <PrĂ€dikat>} {{{ |}}} <Klammern> |- |<ANYPrĂ€dikat> |:= | |- |<BETWEENPrĂ€dikat> |:= |<Spalte> '''BETWEEN''' <Value1> '''AND''' <Value2> |- |<INPrĂ€dikat> |:= |<Spalte> '''IN (''' <Values> ''')''' |- |<ISPrĂ€dikat> |:= |<Spalte> '''IS '''['''NOT'''] [ <Value> {{{ |}}} '''NULL''' ] |- |<LIKEPrĂ€dikat> |:= |<Spalte> ['''NOT'''] '''LIKE''' '''''''<LikeString>'''' '''[ '''ESCAPE''' '''''''<EscapeChar>''''''' ] |- |<LIKEString> |:= |{ <Letter> {{{ |}}} '''%''' {{{ |}}} ''''''_ } % is the wildcard character, _ represents a single character |- |<LogicalOperator> |:= |'''AND''' {{{ |}}} '''OR ''' |- |<NOTINPrĂ€dikat> |:= |<Spalte> '''NOT''' '''IN (''' <Values> ''')''' |- |<VergleichsprĂ€dikat> |:= |<Vergleichsoperand> <Vergleichsoperator> <Vergleichsoperand> |- |<Vergleichsoperator> |:= |'''=''', '''<''', '''>''', '''<>''', '''<=''', '''>=''' |- |<Klammern> |:= |'''( )''' |- |<EXISTPrĂ€dikat> |:= |['''NOT'''] '''EXISTS''' '''('''<Selection>''') '''(s. 6.6.2), wenn mindestens eins exisitiert. |} Die Grenzwerte des BETWEENPrĂ€dikats gehören immer zum spezifizierten Wertebereich. Der erste Wert des BETWEENPrĂ€dikats darf nicht gröĂer als der zweite sein.% steht fĂŒr eine beliebige Zeichenfolge mit 0 bis n Zeichen, _ steht fĂŒr ein einzelnes Zeichen. ====Beispiele/Examples fĂŒr Selektionen==== Der folgende Befehl gibt alle Daten der Tabelle Adressen wieder: SELECT * FROM Adressen; Der Befehl gibt alle Daten des kartesische Produkt der Tabellen Kunde und Verkauf zurĂŒck: SELECT * FROM KUNDE, VERKAUF; Der folgende Befehl zeigt die Verwendung von Aliasen: SELECT A.ID, B.Name FROM Tab1 AS A, Tab2 AS B WHERE A.ID = B.ID; Beispiel fĂŒr Exists: select * from anwender AS A where not exists (select B.AnwenderID from bewertungen AS B where B.BewertungID = 3 and B.BefragungID = 2 and B.AnwenderID = A.ID) Fehlende Foreign Keys: SELECT * FROM `produktattribute` pa WHERE pa.variantennummer NOT IN (SELECT variantennummer FROM preise)
Summary:
Please note that all contributions to Wiki RB4 may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Uwe Heuer Wiki New:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Toggle limited content width