Hướng dẫn mysql new line - mysql dòng mới

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.7K10 Huy hiệu vàng74 Huy hiệu bạc134 Huy hiệu đồng10 gold badges74 silver badges134 bronze badges

Khi được hỏi ngày 25 tháng 5 năm 2010 lúc 7:50May 25, 2010 at 7:50

Muhammed Umermuhammed UmerMuhammed Umer

1.0211 Huy hiệu vàng8 Huy hiệu bạc 6 Huy hiệu Đồng1 gold badge8 silver badges6 bronze badges

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.3K25 Huy hiệu vàng195 Huy hiệu bạc275 Huy hiệu Đồng25 gold badges195 silver badges275 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

Đố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.2K26 Huy hiệu vàng115 Huy hiệu bạc175 Huy hiệu đồng26 gold badges115 silver badges175 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.3832 Huy hiệu vàng18 Huy hiệu bạc11 Huy hiệu đồng2 gold badges18 silver badges11 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: http://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.4125 Huy hiệu vàng39 Huy hiệu bạc61 Huy hiệu Đồng5 gold badges39 silver badges61 bronze badges

1

INSERT INTO myTable VALUES("First line\r\nSecond line\r\nThird line");

JSW189

6.17711 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.2K13 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.2K26 Huy hiệu vàng115 Huy hiệu bạc175 Huy hiệu đồng26 gold badges115 silver badges175 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

  1. 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

    Sentence. Sentence. Sentence
    
    2

    Đã trả lời ngày 3 tháng 5 năm 2012 lúc 14:39

    e.g.

    Sentence. Sentence. Sentence
    
    4
    Sentence. Sentence. Sentence
    
    5
    Sentence. Sentence. Sentence
    
    5

    XTDSXTDS

    Sentence. Sentence. Sentence
    
    6

  2. 2.3832 Huy hiệu vàng18 Huy hiệu bạc11 Huy hiệu đồng

    Sentence. Sentence. Sentence
    
    9
    UPDATE table SET field = REPLACE(field, '. ', '.\r\n')
    
    0
    UPDATE table SET field = REPLACE(field, '. ', '.\r\n')
    
    1
    UPDATE table SET field = REPLACE(field, '. ', '.\r\n')
    
    0
    UPDATE table SET field = REPLACE(field, '. ', '.\r\n')
    
    1

    output:

    UPDATE table SET field = REPLACE(field, '. ', '.\r\n')
    
    2

    Sentence. Sentence. Sentence
    
    4
    Sentence. Sentence. Sentence
    
    5
    Sentence. Sentence. Sentence
    
    5


    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.

Chỉ cần sử dụng nó như thế này:Jun 14, 2012 at 8:02

Hướng dẫn mysql new line - mysql dòng mới

Đầu ra (tính bằng HTML):Airful

Đây là một liên kết đến hướng dẫn: http://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.4125 Huy hiệu vàng39 Huy hiệu bạc61 Huy hiệu ĐồngApr 12, 2021 at 7:42

6.17711 Huy hiệu vàng42 Huy hiệu bạc71 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'));

Đã trả lời ngày 5 tháng 4 năm 2013 lúc 22:05

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:53

David Mdavid m

70.2K13 Huy hiệu vàng154 Huy hiệu bạc184 Huy hiệu đồngOct 2, 2021 at 22:34

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.Payel Senapati

Đã trả lời ngày 25 tháng 5 năm 2010 lúc 8:151 gold badge9 silver badges22 bronze badges

1

Randymorrisrandymorris

INSERT INTO mytable (myfield) VALUES (CONCAT_WS(CHAR(10 using utf8), 'hi this is some text', 'and this is a linefeed.', 'and another'));
0

1.2649 huy hiệu bạc17 Huy hiệu đồngMay 4, 2012 at 10:34

Bạ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.uttam

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.2 gold badges7 silver badges32 bronze badges

Sẽ trông giống như: