mysql - SQL concept: nested loop -



mysql - SQL concept: nested loop -

teacher (userid, name, dob, gender, email, address, phoneno, password, highestqual, isadmin) lesson (lessonid, lessonfee, <teacherid>, <subjectid>) enroll (<studentid>, <lessonid>, <paymentid>,result)

suppose running below sql homecoming 2 tuple identical teacherid.

select teacherid tuition.lesson lessonid in( select lessonid tuition.lesson lessonid not in (( select distinct lessonid tuition.enroll )) );

but if want select names display, result homecoming 1 tuple instead of two.

select name tuition.teacher userid in ( select teacherid tuition.lesson lessonid in( select lessonid tuition.lesson lessonid not in (( selecr distinct lessonid tuition.enroll ))) );

what can result display 2 tuple, same name beingness displayed twice. please help advise.

tuition.teacher has record userid teacher1 , getting 1 record. that's correct. should utilize distinct clause in first query unique teacherid select distinct teacherid tuition.lesson ...

if forcefully want duplicate result, utilize union clause like

select name tuition.teacher userid in ( select teacherid tuition.lesson lessonid in( select lessonid tuition.lesson lessonid not in (( selecr distinct lessonid tuition.enroll ))) ) union select name tuition.teacher userid in ( select teacherid tuition.lesson lessonid in( select lessonid tuition.lesson lessonid not in (( selecr distinct lessonid tuition.enroll ))) )

mysql sql

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -