SQL NOTES FROM Ca

you should learn sql
help me out
D and W are both learning programming languages, but i get the feeling that once you learn how to do it, you can do it faster~
co: is there some kind of book for it?
i'm up for the challenge
i usually just look up what i need
if not there, then there's usually PLENTY of examples on the net
co: cool
Ca: see, what i need is some sort of join, either a left or a right
i always get them mixed up
i have a bunch of IDs in one table, and a bunch of IDs on the other table and what I want to do is find out which IDs don't exist in the first table
co: what is "INNER JOIN"
Ca: if you can figure that out wednesday or friday, let me know =D oo you have admin access
co: what's the inner?
Ca: inner and outer is the same as left and right
co: ok
Ca: just different names
co: and you have a list of ID numbers
and you want to see which ones don't exist?
Ca: nod
co: hmmm ok
Ca: you have access to the database
so what you're doing are all select statements
i want to see which IDs are in the plants_profile table which are NOT in the plants table
because those IDs need to be deleted
I don't want you to delete though, just give me the SQL statements that you figured out
and to get the IDs from the plants table you do this: select plant_id from plants
co: ok
i'm scared to delete anyway
might mess something up
Ca: to get the IDs from the plants_profile table, you do this: select distinct plant_id from plants_profile
so now you have to find the join to connect them
usually it looks something like this
co: what is the * ?
and can you combine like in html?
such as FROM table_name1 table_name2
Ca: select plant_id from plants inner join plants_profile on plants.plant_id=plants_profile.plant_id
the * is like a wild card, give me all columns from the table
co: oh ok
Ca: there are four statements you can make like the one i just did above
either the plants are first or plants_profile is first, or it's an inner join or an outer join
one of them is going to give you ONLY what's in both tables
one of them is going to give you what's in both tables and put null values where the table on the left doesn't have anything to connect with the table on the right
you might have to do some sort of negating command to get what you need
what happened with the old database is i don't think i implemented the delete function correctly
or something
so there's a bunch of crap in there that shouldn't be in there

No comments:

Post a Comment

INSTANT TIME MACHINE!

CERCA TROVA:

TAG MANIA

music 30 days of music Aerial friday5 hawaii samadhi yoga bikeventure school book la dispute silversun pickups concert lists science touché amoré metric poweryoga hawaii bicycle food live show microbiology movie movies phantogram rooster teeth spring break spring break 2015 vinyl 2010 Book review EmM cardistry cooking destiny reads shopping work Stephen king beach books coffee deafheaven koji movie review pyhiflygirls virology b9 bacteria bus ceremony clothes comics cover drug church earl grey interpol mlt other realms raveonettes roman literature socks sspu sviib taking back sunday tattoo tissu tycho vales 6131 YYY aerial problems amyz art balance and composure batman blood blood bank carnavas catullus cheese coffeesundays culture abuse dengue exercise grouplove gymnastic linguist memories mlt adventures modest mouse molecular motion city soundtrack needle work nightwing no sleep records octopus pacific rim recipe republik review saga scattegories sick summer sunbather tiny cats weezer wiwt yummiestars #hrf2015 2014 accident adult swim singles afi album review anakin anamanaguchi angels and airwaves arcade fire asm atul gawande beer best of birds in a row blast bruises cadence caitlin doughty campy cards carpe noctem casket lottery checklist manifesto chemistry chicago chinese christmas clones of the queen concussion contortion dc comics deathwish delerium descendents descender dragonette dress earth wind and fire emily haines felix cartal fight club fishing fletcher c johnson ghost feet glow flow goodtime boys handstand heart shaped box hematology hip key how to with joel and adam hungry ear hurricane interstellar jawbreaker joe hill lab last look lily allen live lucky hell lululemon lyra makeup manoa martin solveig me first and the gimme gimmes megwin melissa minecraft modern baseball mr mercedes nails ncbi nerves never come undone nicole atkins ofelia orange bang poetry pool ps4 research rick and morty rohnert park rtpodcast sandwich school of seven bells sephora sequencing shameless shave ice shimmering stars sirens sleep small brown bike society of s sorority noise star wars static trap stereochemistry strava sysmex the donnas the killers the modern waikiki the saddest landscape the winter passing there is no learning curve third man records thrice tigers jaw tove lo training for aerial on the ground tron unpopular opinion waiola xcm yeah yeah yeahs #hrf2016 #hrf2017 #myhour #tdf2015 '68 007 100% 11-22-63 16s 1970s 1999 2011 2015 35mm 3hive 7seconds 90s :) @8_semesters @wild_twinkies Carrie Fishbones GITS Godzilla Groundhog Day HST L-cuts L4D2 MCR Pink vans RIP SEM Streptococcus The Great Wall UH a favor house atlantic a girl walks home alone at night abraham lincoln vampire hunter achievement hunter aculpture aesop rock agar aji fry ala moana alam alfa beach allister alt/air american hustle antics art of play atlas genius autoclave b sides backstage bai san bakasana baking ballet bandcamp barbra streisand battlewagon bayonetta beach house beach slang beastie boys beats begiragons big bang theory big grams bike biochem biomusicology bitter clarity uncommon grace black dress blaisdell blink 182 blondie bond boscia brad meltzer brambles brazil brew bridge 9 bro force broke for free bronchial wash burrito buxom buy local calzone campy group campylobacter cancer candida candida albicans candy hearts carrot carrot cake cascade catbird cayetana cdc cheap monday chet faker chinese new year chirashi chloe cho dang chores chozo cinerama circuits circulus cisco kid clarity cloning cls coexist coffee stout coheed and cambria coincidence coli com truise comicon common reactor conference constantine cotq credence clearwater revival cremation crow csf cults cursive dads daiei dan and dave daniel dae kim dashboard david rees day by day records dead weather deadlines dealersgrip death death cab for cutie deep blue deer tick defender class demetri martin destiny 2 detective dee devart dhm diamond youth dick grayson dim mak dinosaur pile up disco discordia discount dance discovery distance/closure divination diy dl dna dntel does it work don quijote donnie darko doodles double ankle hang down the cliff dreamcar dreams dscvry dustin nguyen e. coli ebola edge edward benz 27 times el pintor el-p electric president electricity elle king emb enbalming enjoy your burrito epidemiology eqs esr evenings event evil needle exam exotica fall behind me family fashion fat bob fatale fck fiction firefly fitz and the tantrums flash flash fact flight facilities flight of the conchords flower drum song forever 21 forgettable forgetters formula x fountains of wayne frameworks franz ferdinand fresh cafe friday the 13th fuck yes fulton funeral game of thrones gate gatsby genetics ghost bc ghost in the shell ghost key ghostly giant glass glass animals good charlotte gpc grant imahara grayson green river gtd guardians of the galaxy guest blogger gym class heroes habits haemophilus influenzae haim halloween handwriting harlem harmonica harold harrow hawaii problems heavy circles helena bertinelli hell bunny hello hellogoodbye hematocrit heroquest high water marks history channel hl2 holiday mart homework houdini howl howl gaff gaff hummus hxc i love crazy tags iasip ice cream idea's music and books identity crisis in all dishonesty in and out of control in gratitude instagram instax interpro into the wayside intrepidity ipod iwant iyo udon jack johnson jack white japan jaspas jejuni jellys jimmy fallon jisuk jjak jld jock john wick joy departed joy division jpb julian casablancas justice league justice league dark kaimana kakaako kalapana kapiolani kat von d kegg kent keratin kiki kimchi kimchijeon kingsman kitsune kittygeddon klaxons koolau ballroom korean koundinyasana lab report labyrinth ear latte art lazaretto le castle vania leahi left 4 dead 2 leotard leptospirosis les savy fav let me in lgc library light we made like like drive in lil gothams liquid nitrogen lismore lit little richard llea lol lolita loma prieta longboard lookbook love luster luck lust lust lust lymbyc systym magic magic island magnolia cafe mah jong maiden heist mail day mais2 major league makapuu maldi-tof martin denny marvel matty matheson mavica me earl and the dying girl media memento memento bento mental block gaming meta metamorphoses mf doom michael crichton micr490L midweek mika milk tea mind of a chef miss manners mls adventures modcloth mogwai mohawk monty python monuments men moon moose blood morbid mortdecai motown mr robot mr tea my chemical romance my sharona naked juice narcissus ncis ncisla nerd nerdist new eagle cafe new politics new scene nickleback nicole atikins nightmare before christmas nijiya nimitz no backup plans no doubt noisey nonfiction novo biocin now now oblivion only in youth origa osaka loop line ost ovid pai gow pam pancakes pandemic paramore paranormal activity part time job party past present felix patreon patrick kindlon pcr pe'ahi peanut butter and jelly peb pecan tree penny dreadful peony performance peter pan collar pfam photog physics pikul pita pixies pizza plants plastic metal platelets pointe poker pole polefiction politics popo popoitis portal portugal the man post office potpourri pow wow hawaii prey primer prince prismatic procrastination protein pu er pun punk pyogenes pyromaniac quiche r dorothy wayneright rage ramblings ramen ramones random random weirdos rap record shop dude records red machine redbone reflective replacements revision rhcp ringtone ripd roller skates rooms of the house roxy rozwell kid rsd run for cover run the jewels sailor moon sakura mochi salem's lot salonpas samurai ice cake sapling saves the day scans scarjo scary scorpion sds page sean kingston searching for a pulse sed rate seeking a friend for the end of the world self defense family self published separation sequins seven psychopaths sex pistols sgl shadowplay shaloha sheezus shipping shoes shout out louds show sia sierra nevada sikdorak silly girl sinclair library six feet under skateboard skyfall slipshift smart db smashing pumpkins smoke gets in your eyes snl somnio soundcloud speech and debate sphere spill spyral stamps staph staphylococci star trek starcrawler steam stellastarr* straddle ups strfkr string db suckerpunch suetonius suicide squad suis la lune sunday morning at a funeral sunny day real estate surya namaskar sushi sushi king swedish swim swoon taco tuesday taiyaki tantalus target taste tea taunt tcb technical writing tempura tf2 tguk thanksgiving the angels the audition the bougies the byrds the calm blue sea the chase the get up kids the hives the kingsmen the kinks the las the pipettes the quick the raconteurs the russian the supremes the things we think we're missing the voices the weight of the world the wolfpack the xx there's nothing thieves like us threadless three cheers for sweet revenge thursday ticket to ride tideland time travel tiny me title fight tittibhasana toby todor kobakov tokyo milk tom moffat topshelf records totoro tour de france transfection transformation tricks trojans tv two dots udon uniprot unknowns unrelatableexperience vacation valve vampire vegetables verde verse vertigo vibrio vice video dump volary walking backwards man walmart waning star want to read war washed out wednesday addams welwing what we do in the shadows white house down white stripes whole foods wildhoney wildlife wired won tons workaholics wu xia xbox 360 xbox one xur yoga ball yogagypsy zatanna zero zippys zombie zones