Definition of a View Table like students prevents operation UPDATE on person table [closed]

Definition of a View Table like students prevents operation UPDATE on person table [closed]



students as view which is related To person Table


UPDATE persons
SET persons.EN_FAMILY = 'Test'
WHERE persons.STCODE IN
(SELECT students.PERSONS_STCODE AS STCODE
FROM students
WHERE @Counter > 0
AND students.ID NOT IN
(SELECT sel_lesson.ST_ID
FROM sel_lesson
WHERE sel_lesson.YEAR = @CurrenYear
AND sel_lesson.TERM = @CurrentTerm
GROUP BY sel_lesson.ST_ID)
AND students.STATUS IN('1','14')
);



Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






Is it Oracle or MySQL? And what is the issue? Are you having an error? Which one? Also, say I want to help you, I would need to reproduce the error, but I don't know the structure of involved tables and views, so I can not even try to run this statement. Please edit your question by building a Minimal, Complete, and Verifiable example

– Aleksej
Sep 13 '18 at 7:24






Is MySQL, the sub query work success and return 3 row but In update not work

– ali
Sep 13 '18 at 7:26







So, again, how can I reproduce the error and try to help you? And what does "not work" mean? Does it give an error? Or does it do something unexpected?

– Aleksej
Sep 13 '18 at 7:29






Is there actually a view in this query and if so what is it called?

– P.Salmon
Sep 13 '18 at 7:35






@ali a view has a very specific meaning in sql. You will have a better chance of getting an answer if you publish all your table specifications (and views if there are any) together with sample data as text to the question.

– P.Salmon
Sep 13 '18 at 7:46




1 Answer
1



Try use an inner join


UPDATE persons
INNER JOIN (SELECT students.PERSONS_STCODE AS STCODE
FROM students
WHERE @Counter > 0
AND students.ID NOT IN
(SELECT sel_lesson.ST_ID
FROM sel_lesson
WHERE sel_lesson.YEAR = @CurrenYear
AND sel_lesson.TERM = @CurrentTerm
GROUP BY sel_lesson.ST_ID)
AND students.STATUS IN('1','14') ) T on t.STCODE = persons.STCODE

SET persons.EN_FAMILY = 'Test'






Thank you for your patience,but this query Has Error Like My query

– ali
Sep 13 '18 at 8:20






@ali show me your exact error message ..

– scaisEdge
Sep 13 '18 at 17:52






answay .. added a mssing ) before T on

– scaisEdge
Sep 13 '18 at 17:54

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)