HomeОбразованиеRelated VideosMore From: thenewboston

MySQL Database Tutorial - 22 - How to Join Tables

1787 ratings | 353513 views
Facebook - https://www.facebook.com/TheNewBoston-464114846956315/ GitHub - https://github.com/buckyroberts Google+ - https://plus.google.com/+BuckyRoberts LinkedIn - https://www.linkedin.com/in/buckyroberts reddit - https://www.reddit.com/r/thenewboston/ Support - https://www.patreon.com/thenewboston thenewboston - https://thenewboston.com/ Twitter - https://twitter.com/bucky_roberts
Html code for embedding videos on your blog
Text Comments (148)
James Robert Salud (1 month ago)
thanks it works
emanandchill (3 months ago)
should've used 'AS "Item name" ' to change the column name to differentiate it from the other column named "name".
Javier Vásquez (4 months ago)
THIS VIDEO SAVED MY LIFE
Samuele (6 months ago)
Thanks!
Harshita Nagpal (6 months ago)
hahaha bucky you're so cute.
Charr (6 months ago)
wait hold up, don't you need a Foreign Key for this?
Nadeem Yunus (8 months ago)
Bucky I don't know how should I thank you. You put real efforts into making these videos as understandable as they are for us. Your tutorials have helped me learn Mysql within only a couple of days. I just wish a long healthy life for you. God bless you & thank you!
xuan duan (8 months ago)
hi, do you have the notes for each lecture, includes the queries and explanation?/thanks
westfield90 (9 months ago)
I love how you explain in real life examples
Karthik Mahesh (10 months ago)
So you are the GUY who is selling used diapers from your sister...
abudogana elamin (10 months ago)
keep doing this good thing
Stalwart Armor (10 months ago)
What kind of join was this?
Ana-Maria (1 year ago)
where is the JOIN?
Dkshahran Harris (1 year ago)
hello....juz want to ask....how to show output Address in one box for table add1,add2,add3,poskod,state....plz help me....tq in advanced
kaneez fatima (1 year ago)
very nice video sir ,sir i have 2 table ,i want to joint both and view in one how can i joint this two table A) name,rollno,class,subject and table B) date ,attendance status , how to can joint this table ??? plz
afrida i (1 year ago)
i dont understand how he linked 'seller_id' to the original customer.id as i am just getting 0?
zyxwvutsrqponmlkh (1 year ago)
This is babby level, please show how to do the joins on a lookup table.
Essam DaBoss (1 year ago)
BRO MARRY ME !!!!!
Platoface (1 year ago)
Excellent tutorial. I’ve been writing queries for a month and this will really help me. Thank you.
Shraddha Tapase (1 year ago)
How to do delete and update query using join please tell me
Drumpf Cheeto (1 year ago)
Would it also mork if i say customers.id = items.seller_id?
Sam Tran (1 year ago)
bucky, this video helped me tremendously. the way you explained it is exceptional.
Fahraynk (1 year ago)
Why is seller ID not a foreign key of userId? Why is it named differently?
Kendall Wix (1 year ago)
How do you select a specific row? For example, I want to select a single user's info.
Psychedelic Wolf (8 months ago)
SELECT column_name FROM tbl_name WHERE condition / condition with values. (values inside the the quotation marks) Eg. SELECT name FROM customers WHERE id = '1'; Sorry for my informal english. Not my primary language. Also this is just one of the possible solutions that can work, there may be more and much effective.
krishna thentu (1 year ago)
bucky bro now i found this is a little bit usefull tutorial thank you .
Picuic (1 year ago)
You are a life saver. I was doing the tutorial from W3Schools and I was completely in the dark when I got to the Joins section, I didn't understand how to do it. Your tutorial made it VERY easy to understand. Thanks a bunch, I've liked and subscribed and I'll be sure to follow your tutorial from now on.
Hamza Rana (1 year ago)
No one teaches better than him. Ive learned Python, and now this. All of the tutorials are just the best on the internet.
Egie Tayag (1 year ago)
BUcky the Tuna Teacher LOL
RazieL (1 year ago)
wtf is this shit? he didn't even make a join query... this vid is useless
Hamza Rana (1 year ago)
I am a beginner, and it is definitely not useless for me. You can skip to the next videos, I think he is teaching the JOIN queries there.
legitmontrellthigpen (2 years ago)
why didn't you use the left join function?
vJDiZZ (2 years ago)
Can I put the joined tables together into a Permanent table?
Tina x (2 years ago)
I've looked at a lot of MySQL videos, and this video has very good explanations. Also, its nice that you have some humor too. Thanks!
Rimpy Pannu (2 years ago)
Wow!! You explained it so well 👍👍
Cosor Alexandru (2 years ago)
SELECT `customers`.`id`, `customers`.`name` AS `customer`, `items`.`name` AS `item`, `items`.`cost` FROM `customers` INNER JOIN `items` ON `customers`.`id` = `items`.`seller_id`; A more valid syntax :)
afrida i (1 year ago)
i dont understand how he linked 'seller_id' to the original customer.id as i am just getting 0?
Kishan Kumar (1 year ago)
ref this : http://www.zentut.com/sql-tutorial/sql-inner-join/
Why your query is more valid? I am newbie explain me please.
Mads Hansen (2 years ago)
Wow, you have a really good way of explaining the logic of the sql world. Thanks for the video !
steven lane (2 years ago)
This guys knowledge knows no bounds!!
Kliamframe (2 years ago)
Tunafish lane :)
Phil (3 years ago)
in the query at 6:29, is it also correct to write: WHERE customers.id = items.seller_id?
David Blackjade (9 months ago)
SELECT customers.id, customers.name, items.name, items.cost FROM store.customers, store.items WHERE customers.id=seller_id and customers.id = 13 ORDER BY customers.id
Le Frog (11 months ago)
did you ever find the answer cause i need it :P
dayvs (11 months ago)
how about if I wat an specific id? how do you write it? for example, I wat to know all the items for customer id 13, how i idicate to select this specific ID o the WHERE command?
tkrudi (1 year ago)
thank you wise stranger
Esen S (2 years ago)
+Philip Song yes, he didn't do items.seller_id since it was the only "seller_id" in all of the tables, so it couldn't be jammed up as it would be if he hadn't specified the table for "name" or "id"
Savage Noble (3 years ago)
Why can't production databases be this entertaining?
Karthik Mahesh (1 year ago)
Hahahaha... Sooooo true..
还维诺德 (3 years ago)
No bids for id=2 ? ( ͡° ͜ʖ ͡°)
Devin Gaferno (3 years ago)
Great tutorial! I would also like to know if its possible to turn the results into a new table in the database display on a site using php. Thank you
Jay Suthar (3 years ago)
Thank you so much Bucky your tutorials made it so easy to understand than those hours long lecture.
FleurOlivia (3 years ago)
Omg I finally get this now thank you, I should mention you in my graduation speech. If I ever complete Computer Science it will be solely because of you.
Michael G (5 months ago)
FleurOlivia did you finish?
Saurav Pati (3 years ago)
on equal operator you have to specify customers.id = items.seller_id
Pablo Cid (3 years ago)
Hey guys, a little help over here. Where can I download the tables that Bucky is using? Thanks a lot.
areh guano (2 years ago)
https://drive.google.com/file/d/0B9-DE8DcpkJ6T203YWFqS28wSFE/view
J W (3 years ago)
+Pablo Cid from his forum
Viktor Lekić (3 years ago)
Thank you , tutorial is very clear . I have hearing problem and I couldn't understood a single word you were speaking , but I know this now.
Vu So (3 years ago)
What happens when the WHERE statement specifies two columns that have completely different information/does not match? Depending on the column I choose, I can get some output (instead of empty set) and trying to figure out why that is since the columns have different information.
candh (3 years ago)
joins are probably the trickiest part of mysql. thanks for explaining
Lihim Sidhe (3 years ago)
+Haider Ali Khichi : I agree. have you made any headway?
Jitendra Sahu (3 years ago)
Thank you sir ,Your vidio is really helped me
Xion (3 years ago)
is that customers are sellers at the same time? I dont understand how can customer id equals to sellers id.
allwyn mathias (3 years ago)
+Klose Ho However, its technically correct because he is using ebay as an example in these tutorials wherein the customer is the seller and vice versa.
allwyn mathias (3 years ago)
+Klose Ho Actually bucky should have named his 'customers' table as 'sellers'.
fuck u robertsfuck u robertsfuck u robertsfuck u robertsfuck u roberts
20 seconds 8 minutes. wut
Mikey (3 years ago)
Thank you! Amazing.
Jeremy Tews (4 years ago)
This really helped me out with a custom query I needed for a site. Thank you for posting!
horlakunle23 (4 years ago)
i want to join 3 tables together, pls i need help
Peristilo peris (4 years ago)
It's been a long time since I watched a Buck's video for the first time, but the feeling remains the same: you're the best, man!
Internet Drifter (4 years ago)
Anyone else laugh at "used diaper from my sister"?
Omio Rahman (1 month ago)
+Mc Ezra it's true medical companies make artificial virus for $$
Mc Ezra (1 month ago)
+Omio Rahman funny
Omio Rahman (1 month ago)
+Mc Ezra yu forgot manufacted BOWs
Mc Ezra (1 year ago)
in Africa you folks make us to buy used staff, from pants cars now used diapers.
Anthony Starfield (3 years ago)
Hee hee, that is ... unusual ... to say the least. And this example is for selling pretend things on Ebay. So who does he think is going to buy a used diaper?
JowelleK (4 years ago)
You helped me out a LOT. Your whole youtube page is great for learning some stuff before a test. Thank you ^^
nemnoton (4 years ago)
Very well explained.
CHETAN BANKAR (4 years ago)
SIMPLYYYYYY AWESOME......: -)
David C (4 years ago)
So many videos out there on joins. This one is my favourite!
Billy Piazza (4 years ago)
you are the man. i've been knocking myself out for 24 straight hours trying to figure out my query and you nailed it in 8 minutes! i am in ore of you lol
dennis noriega (4 years ago)
can I put AND statement after the WHERE clause to put another related tables?
Latavish Gardner (4 years ago)
very good explanation. very clear and easy to understand
Tiffany W. (4 years ago)
you do a great jobs on your videos. Do you have anything on Php PDO security?
Ardy Aryan (4 years ago)
Great tutorial, thanks
plezx29 (5 years ago)
Good stuff dude, thanks for your clear and concise tutorial on this
Bhagyashree More (5 years ago)
u can even save dis table using CREATE TABLE table_name as SELECT .....n d whole query ma question is how can u update dis join table because when i enter new values its not refelctd in ma join table..can u help me out in dis??
Ramon Segubre (5 years ago)
LOL! 
leonelp51 (5 years ago)
harry potter ... weedwacker ... nvm, good tutorial.
Ahmed Albusaidi (5 years ago)
Thanks :)
RobertKaydoo (5 years ago)
Great tutorial! Thank you for making a posting. I am still getting my head around joins and their purpose so please excuse a beginner's question: is the general purpose of a join to retrieve with a single query what might take 2 or more queries? Thanks again. Peace.
Koen van den Brink (4 years ago)
joining tables is a complicated word for using two or more tables in one command
Dario Volarić (5 years ago)
item: 'used diaper from my sister'??? LOL
Viking102938 (5 years ago)
4:26 Mofos must really need dem gem socks. ..also, how did they each bid (a minimum of 500 pennies) but the socks are under $3? People spending fraction pennies or somethin'? Some Scroogin' goin' on up in this 'ere :V
Stanner (5 years ago)
This could really come in handy! Thanks :) 
Shirt Off (5 years ago)
what program is this? i'm using MySQL workbench and this looks more user friendly
Chris Bence (2 years ago)
Shirt Off this looks like phpmyadmin, it's pretty handy!
axel sok (5 years ago)
1.36-1.38
digitizerSF (5 years ago)
The title refers to the JOIN operation but I don't see it.
Marcos Pereira (5 years ago)
why do you have a moustache
James Abuda (5 years ago)
Do mySQL have features like MS Access which I can join tables by GUI and not hard coding?
gvh1993 (5 years ago)
I have a question.. isn't it better to use the INNER JOIN & ON function? like this: SELECT c.id, c.name, i.name, i.cost FROM customers c INNER JOIN item i ON c.id = i.id ORDER BY c.id;
RUKA clMortality (5 years ago)
you should never do that. repetitive information is not to be stored on database. use it just to geather the information to display to the user
BDUFFS (5 years ago)
Hey, this wasn't a twenty second tutorial!
Adventpenguin (5 years ago)
Thank you very much for this video, I am an intern for a computer games company and the only task I got is to program a database for the products that the company sells. I have been trying to understand joins for 3 month now and now I finally made it thanks to this tutorial.
User03fiction (5 years ago)
Weren't you worried about some perv buying your sister's diaper and doing "stuff" with it?
pinkfl0ss (5 years ago)
yur tutorials r like life lines , yu stop it , da population decreases,
Kill The Wall (5 years ago)
bucky for president!
Steven Feng (5 years ago)
I am not using the same program as Bucky but from what is you need to name all the table right and make sure they are under the same schema. This is how I write it: SELECT Info.id, Info.name, items.name, items.price FROM datainfo123.Info, datainfo123.items WHERE items.id=seller_id Order BY seller_id; I got the same result as him but I name the table different.
Lars Dreier (5 years ago)
Thank you so freakin' much!!
Boris Lemer (5 years ago)
XD my uncle was scarying me with "WAIT TILL YOU GET TO JOINING TABLES" so funny, amazing tutorial THX Bucky!!!
escapegrl1 (5 years ago)
Help I types exactly like Bucky but I get a different result: SELECT customers.id, customers.name, items.name, items.cost FROM customers, items WHERE customers.id=seller_id ORDER BY customers.id Result: ID name cost 1 Bucky Roberts bucket etc. No cost but name of item in that field instead. What am I doing wrong??? I seen no difference.
Harris Mogale (6 years ago)
HI Bucky, listen i get what you did.now how does one create a new table with the results on the query you executed
tenjin09 (6 years ago)
dude, thenewboston, you saved my butt this semester. Thanks for your help on java and mySQL. I can't find any good information on these programs. It seems like everyone is keeping the actual code a secret. Thanks man
feot1000 (6 years ago)
I never comment on videos, but THANK YOU.
Insomniac10102 (6 years ago)
That's pretty easy. Let's pretend we have a 3rd table named "info" that holds the quantity of items bought at once (e.g. 2 used diapers.). We would add it to the list using: SELECT customers.id, customers.name, items.name, items.cost, info.amount Then add the table to the FROM statement: FROM customers, items, info If the amount of items is unequal, you'll get a wacky table with multiples of things. This is because MySQL will make a ratio of all items to make an equal amount of every column
Gerald Scholz (6 years ago)
i'm new to mysql and this helped me so much! thank you!
King Manchester (6 years ago)
uhmm, do you have a tut about joining more than 2 tables?
Mithun Sudheendran (6 years ago)
will these quries work in wamp server phpmyadmin SQL box?
Anthony Vipond (6 years ago)
I guess you mean to say items.seller_id . Anyways, its not necessary here because of the two tables, theres only one column called seller_id, so we dont need to prepend the table name to uniquely identify it
Paul Harbuz (6 years ago)
great job bucky!! keep up the good work.
de Jager (6 years ago)
I suppose you mean "items.seller_id". You definitely could do "items.seller_id" to explicitly specify in which table the 'seller_id' can be found but in this case there is no 'seller_id' in the 'customers' table so there is no ambiguity for the DBMS. He uses 'customers.id' because both the 'customers' and the 'items' table contain a column with the name 'id'. Hope this clarifies!
Danos Chatzopoulos (6 years ago)
Best join tutorials .Bucky is the best online teacher .i ve learned java,c++,javascript and now sql thanks to him .ty dude

Would you like to comment?

Join YouTube for a free account, or sign in if you are already a member.