Ai đó có thể cho tôi biết cách thêm một dòng mới vào một văn bản mà tôi nhập vào bảng MySQL không?
Tôi đã thử sử dụng
INSERT INTO mytable [myfield] VALUES [CONCAT_WS[CHAR[10 using utf8], 'hi this is some text', 'and this is a linefeed.', 'and another']];
1 trong dòng tôi đã nhập với câu lệnh INSERT INTO mytable [myfield] VALUES [CONCAT_WS[CHAR[10 using utf8], 'hi this is some text', 'and this is a linefeed.', 'and another']];
2 nhưng INSERT INTO mytable [myfield] VALUES [CONCAT_WS[CHAR[10 using utf8], 'hi this is some text', 'and this is a linefeed.', 'and another']];
1 được hiển thị như hiện tại.Trên thực tế, tôi đã tạo một bảng trong truy cập MS với một số dữ liệu. MS Access thêm dòng mới với
INSERT INTO mytable [myfield] VALUES [CONCAT_WS[CHAR[10 using utf8], 'hi this is some text', 'and this is a linefeed.', 'and another']];
1. Tôi đang chuyển đổi dữ liệu bảng truy cập MS thành MySQL. Nhưng khi tôi chuyển đổi, INSERT INTO mytable [myfield] VALUES [CONCAT_WS[CHAR[10 using utf8], 'hi this is some text', 'and this is a linefeed.', 'and another']];
1 bị bỏ qua và tất cả văn bản được hiển thị trong một dòng khi tôi hiển thị nó từ bảng MySQL trên biểu mẫu PHP.Bất cứ ai có thể cho tôi biết làm thế nào MySQL có thể thêm một dòng mới vào một văn bản? Đang chờ phản hồi, cảm ơn !!
Alexis Wilke
17.8K10 Huy hiệu vàng77 Huy hiệu bạc135 Huy hiệu đồng10 gold badges77 silver badges135 bronze badges
Khi được hỏi ngày 25 tháng 5 năm 2010 lúc 7:50May 25, 2010 at 7:50
1
Nếu bạn ổn với lệnh SQL lan rộng trên nhiều dòng, thì đề xuất của OEDO là dễ nhất:
INSERT INTO mytable [myfield] VALUES ['hi this is some text
and this is a linefeed.
and another'];
Tôi chỉ có một tình huống mà tốt hơn là có câu lệnh SQL trên một dòng, vì vậy tôi thấy rằng sự kết hợp của
INSERT INTO mytable [myfield] VALUES [CONCAT_WS[CHAR[10 using utf8], 'hi this is some text', 'and this is a linefeed.', 'and another']];
6 và INSERT INTO mytable [myfield] VALUES [CONCAT_WS[CHAR[10 using utf8], 'hi this is some text', 'and this is a linefeed.', 'and another']];
7 đã làm việc cho tôi.INSERT INTO mytable [myfield] VALUES [CONCAT_WS[CHAR[10 using utf8], 'hi this is some text', 'and this is a linefeed.', 'and another']];
Đã trả lời ngày 11 tháng 2 năm 2011 lúc 18:10Feb 11, 2011 at 18:10
Don Kirkbydon KirkbyDon Kirkby
49,7K25 Huy hiệu vàng197 Huy hiệu bạc277 Huy hiệu đồng25 gold badges197 silver badges277 bronze badges
2
Trong một truy vấn SQL thực tế, bạn chỉ cần thêm một dòng mới
INSERT INTO table [text] VALUES ['hi this is some text
and this is a linefeed.
and another'];
Đã trả lời ngày 25 tháng 5 năm 2010 lúc 7:54May 25, 2010 at 7:54
Chrischrischris
9,4451 Huy hiệu vàng25 Huy hiệu bạc26 Huy hiệu đồng1 gold badge25 silver badges26 bronze badges
Đối với hồ sơ, tôi muốn thêm một số lần phá vỡ dòng vào dữ liệu hiện có và tôi đã có
INSERT INTO mytable [myfield] VALUES [CONCAT_WS[CHAR[10 using utf8], 'hi this is some text', 'and this is a linefeed.', 'and another']];
8 để hoạt động tốt ...Dữ liệu mẫu:
Sentence. Sentence. Sentence
Tôi đã làm:
UPDATE table SET field = REPLACE[field, '. ', '.\r\n']
Tuy nhiên, nó cũng hoạt động chỉ với
INSERT INTO mytable [myfield] VALUES [CONCAT_WS[CHAR[10 using utf8], 'hi this is some text', 'and this is a linefeed.', 'and another']];
9 và chỉ INSERT INTO mytable [myfield] VALUES [CONCAT_WS[CHAR[10 using utf8], 'hi this is some text', 'and this is a linefeed.', 'and another']];
8.
hơi xanh
25.3K26 Huy hiệu vàng116 Huy hiệu bạc176 Huy hiệu đồng26 gold badges116 silver badges176 bronze badges
Đã trả lời ngày 10 tháng 12 năm 2010 lúc 16:52Dec 10, 2010 at 16:52
MattmattMatt
2713 Huy hiệu bạc2 Huy hiệu đồng3 silver badges2 bronze badges
6
INSERT INTO test VALUES['a line\nanother line'];
INSERT INTO mytable [myfield] VALUES [CONCAT_WS[CHAR[10 using utf8], 'hi this is some text', 'and this is a linefeed.', 'and another']];
8 Chỉ hoạt động tốt ở đâyĐã trả lời ngày 3 tháng 5 năm 2012 lúc 14:39May 3, 2012 at 14:39
XTDSXTDSxtds
2.3932 Huy hiệu vàng18 Huy hiệu bạc12 Huy hiệu đồng2 gold badges18 silver badges12 bronze badges
2
MySQL có thể ghi lại các dòng điện tốt trong hầu hết các trường hợp, nhưng vấn đề là, bạn cần các thẻ
INSERT INTO table [text] VALUES ['hi this is some text
and this is a linefeed.
and another'];
2 trong chuỗi thực tế cho trình duyệt của bạn để hiển thị các lần nghỉ. Vì bạn đã đề cập đến PHP, bạn có thể sử dụng hàm INSERT INTO table [text] VALUES ['hi this is some text
and this is a linefeed.
and another'];
3 để chuyển đổi ký tự LineBreak ["INSERT INTO mytable [myfield] VALUES [CONCAT_WS[CHAR[10 using utf8], 'hi this is some text', 'and this is a linefeed.', 'and another']];
8"] thành thẻ HTML INSERT INTO table [text] VALUES ['hi this is some text
and this is a linefeed.
and another'];
2.INSERT INTO table [text] VALUES ['hi this is some text
and this is a linefeed.
and another'];
3 function to convert a linebreak character ["INSERT INTO mytable [myfield] VALUES [CONCAT_WS[CHAR[10 using utf8], 'hi this is some text', 'and this is a linefeed.', 'and another']];
8"] into HTML
INSERT INTO table [text] VALUES ['hi this is some text
and this is a linefeed.
and another'];
2 tag.Chỉ cần sử dụng nó như thế này:
Đầu ra [tính bằng HTML]:
Hello, World!
I hate you so much
Đây là một liên kết đến hướng dẫn: //php.net/manual/en/function.nl2br.php
Đã trả lời ngày 30 tháng 11 năm 2014 lúc 11:27Nov 30, 2014 at 11:27
starleaf1starleaf1starleaf1
2.4726 Huy hiệu vàng39 Huy hiệu bạc62 Huy hiệu Đồng6 gold badges39 silver badges62 bronze badges
1
INSERT INTO myTable VALUES["First line\r\nSecond line\r\nThird line"];
JSW189
6.19711 Huy hiệu vàng42 Huy hiệu bạc71 Huy hiệu đồng11 gold badges42 silver badges71 bronze badges
Đã trả lời ngày 5 tháng 4 năm 2013 lúc 22:05Apr 5, 2013 at 22:05
0
Trước hết, nếu bạn muốn nó được hiển thị trên biểu mẫu PHP, phương tiện là HTML và do đó, một dòng mới sẽ được hiển thị bằng thẻ
INSERT INTO table [text] VALUES ['hi this is some text
and this is a linefeed.
and another'];
2. Kiểm tra nguồn HTML của trang - bạn có thể có dòng mới được hiển thị chỉ dưới dạng ngắt dòng, trong trường hợp đó, vấn đề của bạn chỉ đơn giản là một trong việc dịch văn bản cho đầu ra sang trình duyệt web.Đã trả lời ngày 25 tháng 5 năm 2010 lúc 7:53May 25, 2010 at 7:53
David Mdavid mDavid M
70.3K13 Huy hiệu vàng154 Huy hiệu bạc184 Huy hiệu đồng13 gold badges154 silver badges184 bronze badges
Trong SQL hoặc MySQL, bạn có thể sử dụng các chức năng
INSERT INTO table [text] VALUES ['hi this is some text
and this is a linefeed.
and another'];
7 hoặc INSERT INTO table [text] VALUES ['hi this is some text
and this is a linefeed.
and another'];
8 để nhập vào ASCII 13 cho nguồn cấp dữ liệu trở lại vận chuyển, tương đương INSERT INTO mytable [myfield] VALUES [CONCAT_WS[CHAR[10 using utf8], 'hi this is some text', 'and this is a linefeed.', 'and another']];
8. Nhưng như @David M đã tuyên bố, rất có thể bạn đang muốn có HTML cho thấy sự phá vỡ này và AR là những gì sẽ hoạt động.
hơi xanh
25.3K26 Huy hiệu vàng116 Huy hiệu bạc176 Huy hiệu đồng26 gold badges116 silver badges176 bronze badges
Đã trả lời ngày 10 tháng 12 năm 2010 lúc 16:52May 25, 2010 at 8:15
MattmattRandyMorris
2713 Huy hiệu bạc2 Huy hiệu đồng9 silver badges17 bronze badges
1
8 Chỉ hoạt động tốt ở đâyINSERT INTO mytable [myfield] VALUES [CONCAT_WS[CHAR[10 using utf8], 'hi this is some text', 'and this is a linefeed.', 'and another']];
2Sentence. Sentence. Sentence
Đã trả lời ngày 3 tháng 5 năm 2012 lúc 14:39
e.g.
4Sentence. Sentence. Sentence
5Sentence. Sentence. Sentence
5Sentence. Sentence. Sentence
XTDSXTDS
6Sentence. Sentence. Sentence
2.3932 Huy hiệu vàng18 Huy hiệu bạc12 Huy hiệu đồng
9Sentence. Sentence. Sentence
0UPDATE table SET field = REPLACE[field, '. ', '.\r\n']
1UPDATE table SET field = REPLACE[field, '. ', '.\r\n']
0UPDATE table SET field = REPLACE[field, '. ', '.\r\n']
1UPDATE table SET field = REPLACE[field, '. ', '.\r\n']
output:
2UPDATE table SET field = REPLACE[field, '. ', '.\r\n']
4Sentence. Sentence. Sentence
5Sentence. Sentence. Sentence
5Sentence. Sentence. Sentence
MySQL có thể ghi lại các dòng điện tốt trong hầu hết các trường hợp, nhưng vấn đề là, bạn cần các thẻ
2 trong chuỗi thực tế cho trình duyệt của bạn để hiển thị các lần nghỉ. Vì bạn đã đề cập đến PHP, bạn có thể sử dụng hàmINSERT INTO table [text] VALUES ['hi this is some text and this is a linefeed. and another'];
3 để chuyển đổi ký tự LineBreak ["INSERT INTO table [text] VALUES ['hi this is some text and this is a linefeed. and another'];
8"] thành thẻ HTMLINSERT INTO mytable [myfield] VALUES [CONCAT_WS[CHAR[10 using utf8], 'hi this is some text', 'and this is a linefeed.', 'and another']];
2.INSERT INTO table [text] VALUES ['hi this is some text and this is a linefeed. and another'];
Chỉ cần sử dụng nó như thế này:Jun 14, 2012 at 8:02
Đầu ra [tính bằng HTML]:Airful
Đây là một liên kết đến hướng dẫn: //php.net/manual/en/function.nl2br.php2 silver badges12 bronze badges
7
Đã trả lời ngày 30 tháng 11 năm 2014 lúc 11:27
2.4726 Huy hiệu vàng39 Huy hiệu bạc62 Huy hiệu ĐồngApr 12, 2021 at 7:42
6.19711 Huy hiệu vàng42 Huy hiệu bạc71 Huy hiệu đồng
Đã trả lời ngày 5 tháng 4 năm 2013 lúc 22:05Trước hết, nếu bạn muốn nó được hiển thị trên biểu mẫu PHP, phương tiện là HTML và do đó, một dòng mới sẽ được hiển thị bằng thẻ
INSERT INTO table [text] VALUES ['hi this is some text
and this is a linefeed.
and another'];
2. Kiểm tra nguồn HTML của trang - bạn có thể có dòng mới được hiển thị chỉ dưới dạng ngắt dòng, trong trường hợp đó, vấn đề của bạn chỉ đơn giản là một trong việc dịch văn bản cho đầu ra sang trình duyệt web.Đã trả lời ngày 25 tháng 5 năm 2010 lúc 7:53
David Mdavid m
70.3K13 Huy hiệu vàng154 Huy hiệu bạc184 Huy hiệu đồng
Trong SQL hoặc MySQL, bạn có thể sử dụng các chức năng
INSERT INTO table [text] VALUES ['hi this is some text
and this is a linefeed.
and another'];
7 hoặc INSERT INTO table [text] VALUES ['hi this is some text
and this is a linefeed.
and another'];
8 để nhập vào ASCII 13 cho nguồn cấp dữ liệu trở lại vận chuyển, tương đương INSERT INTO mytable [myfield] VALUES [CONCAT_WS[CHAR[10 using utf8], 'hi this is some text', 'and this is a linefeed.', 'and another']];
8. Nhưng như @David M đã tuyên bố, rất có thể bạn đang muốn có HTML cho thấy sự phá vỡ này và AR là những gì sẽ hoạt động.Oct 2,
2021 at 22:34
Đã trả lời ngày 25 tháng 5 năm 2010 lúc 8:15Payel Senapati
Randymorrisrandymorris1 gold badge10 silver badges22 bronze badges
1
1.2649 huy hiệu bạc17 Huy hiệu đồng
INSERT INTO mytable [myfield] VALUES [CONCAT_WS[CHAR[10 using utf8], 'hi this is some text', 'and this is a linefeed.', 'and another']];
0Bạn phải thay thế
INSERT INTO mytable [myfield] VALUES [CONCAT_WS[CHAR[10 using utf8], 'hi this is some text', 'and this is a linefeed.', 'and another']];
8 bằng Sentence. Sentence. Sentence
1 trước khi đưa vào cơ sở dữ liệu.May 4, 2012 at 10:34
Trong trường hợp này trong bảng cơ sở dữ liệu, bạn sẽ thấy
Sentence. Sentence. Sentence
1 thay vì dòng mới.uttamSẽ trông giống như:2 gold badges7 silver badges33 bronze badges