2time Posted February 8, 2014 Report Share Posted February 8, 2014 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))students4 | student4 | 25 | student5 | 3classes:1 | mathematics | 3452 | biology | 784 | english | 112class_rooms:34578112si trebe sa extrag din aceste tabele cu un query ca sa imi iasa asa rezultatul student1 | 5 | 345 | mathematicsstudent2 | 5 | 345 | mathematicsstudent3 | 5 | 345 | mathematicsam 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 ? Quote Link to comment Share on other sites More sharing options...
Robert1995 Posted February 8, 2014 Report Share Posted February 8, 2014 Hai ca incerc eu asa "pe sec" netestat .SELECT s.name, s.id, crm.class_room_number, crm.name FROM students s LEFT JOIN classes ON class_room_number crm = 345 Quote Link to comment Share on other sites More sharing options...