将 mysql LONGTEXT 值转换为 VARCHAR 值? [英] Convert mysql LONGTEXT value to VARCHAR value?

查看:795
本文介绍了将 mysql LONGTEXT 值转换为 VARCHAR 值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个功能可以在用户的​​ facebook 墙上发帖.

我发送到 facebook 的一件事是我从设置为 LONGTEXT 的 mysql 表中获取的一些文本.如果我将表格设置为 LONGTEXT,则文本不会发送到 facebook,但如果我将表格设置为 VARCHAR,则文本将发送到 facebook!

那么如何在我将得到的 LONGTEXT 值转换成一个 VARCHAR 值,然后再将它发送到 Facebook?

我在许多其他地方使用该表,所以我无法将表本身转换为 VARCHAR,它需要做很多工作!我必须转换输出.

感谢任何输入!

解决方案

mysql中你可以:

<前><代码>SELECT ID, CAST(YourLongText as char(255)) AS YourVarchar FROM some_table

你是那个意思吗

I have a function that post on a users facebook wall.

One thing that I send to facebook is some text that I get from my mysql table that is set to LONGTEXT. If I have the table set as LONGTEXT then the text is not send to facebook, but if I set the table to VARCHAR then the text is send to facebook!

So how can I convert the LONGTEXT value that I get so it becomes like a VARCHAR value, before I send it to facebook?

I use the table in many other places so I just cant convert the table itself to VARCHAR, its to much work! I have to convert the output instead.

Any input appreciated thanks!

解决方案

In mysql you can do:


SELECT ID, CAST(YourLongText as char(255)) AS YourVarchar FROM some_table

Did you mean like that

这篇关于将 mysql LONGTEXT 值转换为 VARCHAR 值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆