Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

SQL Part1

SQL lesson
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
2 views

SQL Part1

SQL lesson
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 5
‘Sample Relations ren (anette, sry, oot) {at (cat, re hae, ooo sey, COR, say brace) ropeyroret (ropes, ae peste, pe, ome, et owe, a, eam) ‘hatchet, Mame, ne, io, eyes) Frtcrnar (omnes ame, Ma, se, 2) ‘ining (lan, pope, vee, conme) FRegraten (cher, bare eho, detions) Data Manipulation SELECT —1o quar dunn he daabas, INSERT insets able UPDATE —to update datn ina table DELETE to delete data on ble, UTERALS SELECT (DISTINCT) ALL] (*|esunrsirnaon [AS neo -]} FROM reo1aare [ae +] [WHERE consucn] [GROUP BY ser (HAVING conan} [ORDER BY curve) FROM specifi thetic or tubesto beused TWIIERE tte tie rss abjoao ome contin (GROUP BY forms group uftows wa be same column value HAVING Bites he groups sbjt tome codon SELECT spesifies which corms eo spp in he ouput ORDER DY ayes the ona of te ouput Retiove ati colurons, al rows. Ut cea of alsa EXAMPLE: SELECT ume mane, seve, pst, ser 008, yt Frost seurcr+ Frow sur stato | wane | wName | postion [= [= ‘salary | branch sit foam | woe [aise fot | rons | sno | wes Sos7 | aan | Beech | Assam | F | 10Nor40 | t20noo | pans sor | Dit | Few | Sorter | at | 2atese | isxnoo | pms Sno) | ay) | one | asm | Ff ro | sono | aor sos | Suan | Bani | smeer | F | 300 | 240000 | pons su fue | Lee | asian | F | names | some | as Retieve specific columns, al ows Prosi # foto ales rate Stenng any he Sta number th nd istrames, adh saint ‘amo | mame | Name | sary sia1 | soi | white | 20000 sax? | Ann | Beech | 1200000 soit | Daas | Fort | 1400000 sao | Mary | Hove | 9000.00 sos | Suan | Brand | 2400000 sat | soie | tee | 90000 Calculated fies. Prcuce ast of moth slanesforal staf showing te staff number the Rt and et ‘ames, and he sal cea. EXAMPLES: SELECT set, ian, tans, !12 SELECT stam, mane, hae,aly/2 AS mois FROM ser ‘Sano | Name | name | coe si2r | sotn | wae | 2500.00 3637 | An | Beech | 100000 ser | Diie | Fert | 1500.0 sao | Mary | Howe | 75000 ses | sesin | Brand | 2000.00 siti | Jute | Le | 7500 ‘BASIC SEAR3H CONDITIONS (WHERE CLAUSE) + Comparison Compare va of one expression the ale f anh expression + Range Tet wher the vl of expressen ale wine specifi range of ss, {Set membership Tet aber the vale of an ereson eae oe fae of vals 1S Paacn match Test wel sng mulches species pte, 2 Mud Tester ecoluns has nll knows) vale Comparison search condition. Lis tt nn str grater than £10.00 EXAMPLES: SELECT sss tans, None roster, say FROM sit (WHERE salery> 10000, afte | tome | wane | postion | satay star [tone | white [ Momger | 3000.00 sa37 | Ana | Beech | Asisanr | 1200000 scid | David | Fort | Supervisor | 1800000 | ses | sown | Brat | sneer | 2000 | In SQL, the following simple compariaon operators er aviable: equals <> not equalto (180 sandr! is not oqualto (allowed in some dlc) ‘iets than <= x thon or ua to. Sigreater than >= greater ha o pal to AND, OR, and NOT ‘Compound comparison search condition, Ls th axchasses ofa ranch ofces in London lego EXAMPLES: sELECT* FROM Barer WHERE cry~ ‘London! OR = 20000 AND sty <= 30000; sattio | ‘mame | Name | postion | salary stat | Join | White | Manager | 2000000 sos_| swan | Brant | manser | 100000 ‘Set membership search condition (INNOT IN). Ls manager an supsrvsor, EXAMPLES: SELECT sxe, are, None pst FROM set WHERE poeton IN (anape"Supesisr), SELECT stat, thae, Name poston FROM out "Manage OR penton ='Sopervisn’ WHERE peat stamio | miame | seme | postion sizr | doi | wate | Manger soit | David | Fart | Supervisor sos | Sesan | Brand | Manoger Patter match sesrch condition (LIKEJNOT LIKE). Finda owns wih to sting ‘lasgow nthr mec SQL bas ro special putern-snathig symbols: 1% peroent character presen sequence of oor more careers (leon) + undersore chars repress a ingle chaste: [ESCAPE CHARACTERS: LIKE "180 ESCAPE EXAMPLES: SELECT omen, Mane, tans, sires ole FROM Prvateomee WHERE actrees LIKE "Glasgow, ‘wnerno | mNeme | iname | aaaress vein. cos? | Carot | Faret | 6 Achy St Gligow G32 9DX | O141357-7419 com | Tin | Murphy | 65 Wel St,Glsgow Gir | O141-983.1728 {com | tomy | sume | 12pm cingow coon | ov225.105 [NULL search coneition '$ NULLIIS NOT NULL). Lt ede caving on prope POX we & Comet na fol Don spied {Gemumpte= POS AND conmet =") Gente «PO AND sonnet <> to et) EXAMPLE10: SELECT srs oso FROM vero WHERE poneNo="PO4" AND coms IS NUL.

You might also like