Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私はデータを含むテーブルを持っています:
000001 123 00123 123456 1234 mydog 04456mydog
そして、すべての数値を<10000次のように 4 桁でフォーマットします。
<10000
0001 0123 0123 123456 1234 mydog 04456mydog
どうすればこれを達成できますか?
1 つの可能なアプローチ:
UPDATE test SET digits = LPAD(CAST(digits AS UNSIGNED), 4, '0') WHERE digits REGEXP '^[0-9]+$' AND CAST(digits AS UNSIGNED) < 10000;
SQLフィドル。