Jump to content
2time

Query

Recommended Posts

am tabelele urmatoare

students(id int not null, name varchar(10), year int, primary key (id asc))

classes(id int not null, name varchar(15), class_room_number int, primary key (id asc))

class_rooms(number int not null, primary key (number asc))

students

4 | student4 | 2

5 | student5 | 3

classes:

1 | mathematics | 345

2 | biology | 78

4 | english | 112

class_rooms:

345

78

112

si trebe sa extrag din aceste tabele cu un query ca sa imi iasa asa rezultatul

student1 | 5 | 345 | mathematics

student2 | 5 | 345 | mathematics

student3 | 5 | 345 | mathematics

am incercat cu formula asta :"select name , year from students where year='5' union select name,class_room_number from classes where class_room_number='345'" dar nu mi le aseaza asa din cauza ca am name in ambele tabele ns cum sa le separ ma poate ajuta careva ?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...