barca883 2023-1-4 10:40
有個 PHP program 駁去 MySQL 行幾條不同 SQL, 個 program 行左好幾年都正常, 但上個月開始突然失靈, 由上到下逐條 SQL check 發覺其中一條 hang 住左.
delete from tableA where id in (select id from tableB,tableC where some_conditions group by 1)
如果我分開先行後面 select id from tableB,tableC where some_conditions group by 1 攞晒 id 出來再砌返
delete from tableA where id in (1,2,3,4,5...), 兩條 SQL 都係好快就行完, 但放埋一齊就係 hang 住, 請問師兄有冇遇過咁奇怪既事同知道原因? 唔該晒.
lhcdims 2023-1-6 02:26
[quote]原帖由 [i]barca883[/i] 於 2023-1-4 10:40 發表 [url=https://www.discuss.com.hk/redirect.php?goto=findpost&pid=554978560&ptid=30933463][img]https://www.discuss.com.hk/images/common/back.gif[/img][/url]
有個 PHP program 駁去 MySQL 行幾條不同 SQL, 個 program 行左好幾年都正常, 但上個月開始突然失靈, 由上到下逐條 SQL check 發覺其中一條 hang 住左.
delete from tableA where id in (select id from tableB,tableC where some_conditions group by 1)
... [/quote]
試下咁樣:
DELETE t1
FROM tableA AS t1
JOIN (
SELECT id
FROM tableB, tableC
where some_conditions group by 1)
AS t2
ON t1.id = t2.id
kormer 2023-1-11 00:03
[quote]原帖由 [i]barca883[/i] 於 2023-1-4 10:40 發表 [url=https://www.discuss.com.hk/redirect.php?goto=findpost&pid=554978560&ptid=30933463][img]https://www.discuss.com.hk/images/common/back.gif[/img][/url]
有個 PHP program 駁去 MySQL 行幾條不同 SQL, 個 program 行左好幾年都正常, 但上個月開始突然失靈, 由上到下逐條 SQL check 發覺其中一條 hang 住左.
delete from tableA where id in (select id from tableB,tableC where some_conditions group by 1)
... [/quote]
咁樣呢?
delete from tableA where `id` in (select id from tableB,tableC where some_conditions group by 1)
kckcp 2023-1-12 17:24
有沒試不經PHP行? 會不會是HTTP / HTTPS 問題?
howevera 2023-1-16 08:49
咁樣會唔會快 d?
delete from tableA where id in (select distinct id from tableB,tableC where some_conditions)
esprithk 2023-1-20 23:29
如果無記錯.
新版本的 php 7.4 - 8.1 都不能只有group by
你需要定一個start (開始位)
你的web hosting是否已經不再支援php 5.6?
[[i] 本帖最後由 esprithk 於 2023-1-21 10:23 編輯 [/i]]
kormer 2023-1-21 00:57
[quote]原帖由 [i]esprithk[/i] 於 2023-1-20 23:29 發表 [url=https://www.discuss.com.hk/redirect.php?goto=findpost&pid=555393999&ptid=30933463][img]https://www.discuss.com.hk/images/common/back.gif[/img][/url]
如果無記錯.
新版本的 php 7.4 - 8.1 都不能只有group by 1
你需要定一個start & end (開始位和結束位)
你的web hosting是否已經不再支援php 5.6? [/quote]
php 的 mysql connector不支持 group by 1?
esprithk 2023-1-21 10:05
[quote]原帖由 [i]kormer[/i] 於 2023/1/21 00:57 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=555395364&ptid=30933463][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]
php 的 mysql connector不支持 group by 1? [/quote]
首先, 你的網站一直運行. 理論上應該不會突然會出現問題.
所以, 你需要去登入web hosting來確認是否全面升級了php7.4或以上的版本?
有關php7.4以上寫法,
以往預設是由第1個數據開始計算。
現在新寫法是需要設定是由那一個位開始來作為數據提取的準確位置。
所以,你要加番
start from where,
和 需要多少條數據
你嘗試這樣寫法
[attach]13938389[/attach]
另外, 你的 group by 1 是什麼意思?
應該是 group by "column name"
更多資料
[url=https://www.w3resource.com/sql/group-by.php]https://www.w3resource.com/sql/group-by.php[/url]
[[i] 本帖最後由 esprithk 於 2023-1-21 10:36 編輯 [/i]]
esprithk 2023-1-21 10:31
[quote]原帖由 [i]barca883[/i] 於 2023/1/4 10:40 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=554978560&ptid=30933463][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]
有個 PHP program 駁去 MySQL 行幾條不同 SQL, 個 program 行左好幾年都正常, 但上個月開始突然失靈, 由上到下逐條 SQL check 發覺其中一條 hang 住左.
delete from tableA where id in (select id from tableB,tableC where some_conditions group by 1)
... [/quote]
你有幾個tables, 是否應該會像這樣寫?
以下是2個table的example
[attach]13957872[/attach]
[[i] 本帖最後由 esprithk 於 2023-1-27 23:19 編輯 [/i]]
esprithk 2023-1-21 10:39
[quote]原帖由 [i]kckcp[/i] 於 2023/1/12 17:24 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=555194129&ptid=30933463][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]
有沒試不經PHP行? 會不會是HTTP / HTTPS 問題? [/quote]
https 主要是關於在php寫法要改用
mysql >>> mysqli
例子,
[attach]13938422[/attach]
[attach]13938423[/attach]
kormer 2023-1-21 17:19
[quote]原帖由 [i]esprithk[/i] 於 2023-1-21 10:05 發表 [url=https://www.discuss.com.hk/redirect.php?goto=findpost&pid=555399324&ptid=30933463][img]https://www.discuss.com.hk/images/common/back.gif[/img][/url]
首先, 你的網站一直運行. 理論上應該不會突然會出現問題.
所以, 你需要去登入web hosting來確認是否全面升級了php7.4或以上的版本?
有關php7.4以上寫法,
以往預設是由第1個數據開始計算。
現在新寫法是需要設定是由那一個位開始來作為數據提取的準確位置。
所以,你要加番
start from where,
和 需要多少條數據
你嘗試這樣寫 ... [/quote]
問返樓主好一些吧
esprithk 2023-1-27 23:22
樓主,
在 PHP 8.1 + MySQL 8 的環境下,
這一句會出error
[attach]13957894[/attach]
會出現以下的 error message:
[attach]13957897[/attach]
雖然你沒有寫 LIMIT 0,30 但是系統會自動加入來運行
*以上的30是代表 test table 內的data總數量(行數/row)
*******************************
必須在末段加番 ORDER by才會正常RUN
[attach]13957896[/attach]
[[i] 本帖最後由 esprithk 於 2023-1-27 23:25 編輯 [/i]]
howevera 2023-2-2 08:53
但係樓主係話 hang 住左, 即係 loop 死或等好耐都冇反應? 唔係出 error 喎.
esprithk 2023-2-8 13:44
[quote]原帖由 [i]howevera[/i] 於 2023/2/2 08:53 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=555681344&ptid=30933463][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]
但係樓主係話 hang 住左, 即係 loop 死或等好耐都冇反應? 唔係出 error 喎. [/quote]
就是寫錯左。
樓主應該沒有在browser的developer tools查看 error message。
*或者在phpMyAdmin內設定為 PHP 7.4 或 PHP 8.1
再運行同一句的SQL都能夠查看出了什麼問題。
舊語法在新的PHP 7.4 - 8.1 都不適用。
我是正在將PHP 5.6升級緊去PHP 8.1,修改緊240個程式檔,所以現在清楚了要修那一句。
留意: 樓主一直使用上沒有問題。即是係本身web hosting有些變動。
最簡單是去重新檢查PHP version是否因為web hosting server有大更新系統而改變了。 如果當中有得繼續選擇PHP 5.6就再選PHP 5.6,這樣應該很可能即時解決到問題。不需要任何對網頁的編程內容作修改。
但是,這只是將問題再繼續推遲。最終還是要面對的。
還要注意: 在設定web hosting PHP = 7.4 或 8.1 後,還需要去修改 php.ini
網頁內容,
在PHP 7.4 - 8.1 ,現在Group By 必須要跟隨Order By,否則不會運行。會立刻停止load網頁,卡死。
[[i] 本帖最後由 esprithk 於 2023-2-8 13:47 編輯 [/i]]
頁:
[1]