0
對不起,關於無法讀取的查詢,我在截止日期之前。我設法通過將這個查詢分解爲兩個較小的查詢來解決問題,並在Java中執行一些業務邏輯。仍然想知道爲什麼這個查詢可以隨機時間返回兩個不同的結果。
所以,它隨機返回一次所有預期的結果,其他時間只是一半。我注意到,當我編寫每個連接的join時,並在每次連接後執行,最後它會返回所有預期的結果。所以,如果有某種MySql內存或其他限制,它不會在連接中佔用整個表,就會遊蕩。還閱讀不確定的查詢,但不知道該說什麼。
請幫忙,詢問是否需要澄清,並提前謝謝。
RESET QUERY CACHE;
SET SQL_BIG_SELECTS=1;
set @displayvideoaction_id = 2302;
set @ticSessionId = 3851;
select richtext.id,richtextcross.name,richtextcross.updates_demo_field,richtext.content from
(
select listitemcross.id,name,updates_demo_field,listitem.text_id from
(
select id,name, updates_demo_field, items_id from
(
SELECT id, name, answertype_id, updates_demo_field,
@student:=CASE WHEN @class <> updates_demo_field THEN 0 ELSE @student+1 END AS rn,
@class:=updates_demo_field AS clset FROM
(SELECT @student:= -1) s,
(SELECT @class:= '-1') c,
(
select id, name, answertype_id, updates_demo_field from
(
select manytomany.questions_id from
(
select questiongroup_id from
(
select questiongroup_id from `ticnotes`.`scriptaction` where [email protected] and questiongroup_id is not null
) scriptaction
inner join
(
select * from `ticnotes`.`questiongroup`
) questiongroup on scriptaction.questiongroup_id=questiongroup.id
) scriptgroup
inner join
(
select * from `ticnotes`.`questiongroup_question`
) manytomany on scriptgroup.questiongroup_id=manytomany.questiongroup_id
) questionrelation
inner join
(
select * from `ticnotes`.`question`
) questiontable on questionrelation.questions_id=questiontable.id
where updates_demo_field = 'DEMO1' or updates_demo_field = 'DEMO2'
order by updates_demo_field, id desc
) t
having rn=0
) firstrowofgroup
inner join
(
select * from `ticnotes`.`multipleoptionstype_listitem`
) selectlistanswers on firstrowofgroup.answertype_id=selectlistanswers.multipleoptionstype_id
) listitemcross
inner join
(
select * from `ticnotes`.`listitem`
) listitem on listitemcross.items_id=listitem.id
) richtextcross
inner join
(
select * from `ticnotes`.`richtext`
) richtext on richtextcross.text_id=richtext.id;
這是完全不可讀的。我甚至不知道是否有兩個查詢。請更好地格式化它。 –
它的一個查詢,你現在可以讀嗎? –