0
What good app to learn basic database? (Android)
start with sql server and I don't know how to join table or subquery.
3 Respostas
+ 2
This app provides a perfect introduction course for SQL, just search for it in the courses :)
+ 2
if you have 2 tables:
person
---|-------|-----
id | name | hair
hair
---|------
id | color
Let's say the entries in hair are
1 Blonde
2 Brown
3 Red
4 Black
And the entries in person are
1 Brian 2
2 Sharron 2
3 Annette 1
4 Bill 3
5 Steve 4
6 Mike 3
7 Angelo 2
Okay. The first column in both tables is the unique ID. It is unique to that row in that table. Which means it can be used to join tables. Notice in the person table that the 3rd colum. called hair contains IDs of the hair table. So if you want to get all the people with red hair:
SELECT * FROM `person`, `hair` WHERE `person`.`hair` = `hair`.`id` AND `hair`.`id` = '3';
This would return
4 Bill 3 3 Red
6 Mike 3 3 Red
Instead of the * in the query you could specify the columns you want as
`person`.`name`, `hair`.`color`
and you'd get
Mike Red
Bill Red
The join is when you ask for two tables where the unique ID field in one is equal to a reference to it in another table.
This could be a table of teachers and a table of students they teach. The teacher ID would be in the student table as reference. etc.
This type of relationship is know as a 1 to many. 1 teacher can be related to many students. 1 hair color can be related to many people.
+ 1
Boem Shakalaka thanks I just found it lol