I have 2 tables
and data in tablesCode:create table sem_opjaaine( opID int unsigned not null, aineID varchar(255) not null ); create table sem_ained( kood varchar(255) not null, nimi varchar(255), teade varchar(255), PRIMARY KEY(kood) );
For example, let opID be 1.Code:mysql> select * from sem_opjaaine; +------+-------------+ | opID | aineID | +------+-------------+ | 5 | MTAT.01.001 | | 1 | AABB.32.045 | | 1 | MTAT.01.001 | | 1 | AKAK.01.001 | +------+-------------+ mysql> select * from sem_ained; +-------------+------------------+-------+ | kood | nimi | teade | +-------------+------------------+-------+ | MTAT.01.001 | Ati aine | NULL | | AKAK.01.001 | Mingisugune aine | NULL | | AABB.32.045 | Kolmas Proov | NULL | +-------------+------------------+-------+
I can't figure out select sentence to select rows where opID != 1 and aineID = kood and only get those aineID's, whose opID != 1.
So when opID is 1, i should get nothing, when opID is 5, is should get this:
This is as clear as i can explane itCode:+------+-------------+-------------+ | opID | aineID | kood | +------+-------------+-------------+ | 1 | AKAK.01.001 | AKAK.01.001 | | 1 | AABB.32.045 | AABB.32.045 | +------+-------------+-------------+
Thanks,
Sander





Bookmarks