有没有办法在MySQL中选择带有html标签的列?

时间:2022-03-15 22:26:12

I have a database where some columns have HTML tags in them, IE

我有一个数据库,其中一些列中包含HTML标记,IE

Rot<sub>1</sub>

I try running queries, like

我尝试运行查询,比如

SELECT Rot<sub>1</sub> FROM chem.thermTable;

But I get an error message in my SQL syntax. Putting the column name in quotes simply returns the column name. Typing

但是我在SQL语法中收到错误消息。将列名放在引号中只会返回列名。打字

SELECT * FROM chem.thermTable;

Works but returns other values I don't need as well. I searched and haven't found any solutions. Thanks for your help!

工作,但返回我不需要的其他值。我搜索并没有找到任何解决方案。谢谢你的帮助!

Edit: I am trying to query

编辑:我正在尝试查询

SELECT Method,Basis,Rot<sub>1</sub> from chem.thermtable;

2 个解决方案

#1


1  

You must use back quotes around the column name like this :

您必须在列名称周围使用后引号,如下所示:

SELECT `Rot<sub>1</sub>` FROM chem.thermTable;

IMHO, this a not a clean column name and you should consider renaming it.

恕我直言,这不是一个干净的列名,你应该考虑重命名它。

#2


0  

Are you asking for this?

你在问这个吗?

SELECT ColumnNameX, ColumnNameY, ColumnNameZ FROM chem.thermTable;

Where you'd change the ColumnName X, Y, and Z to be the column names you want. If not, you should perhaps clarify your question with an example of a few rows worth of data.

您将ColumnName X,Y和Z更改为所需的列名称的位置。如果没有,您应该用几行数据的示例来澄清您的问题。

#1


1  

You must use back quotes around the column name like this :

您必须在列名称周围使用后引号,如下所示:

SELECT `Rot<sub>1</sub>` FROM chem.thermTable;

IMHO, this a not a clean column name and you should consider renaming it.

恕我直言,这不是一个干净的列名,你应该考虑重命名它。

#2


0  

Are you asking for this?

你在问这个吗?

SELECT ColumnNameX, ColumnNameY, ColumnNameZ FROM chem.thermTable;

Where you'd change the ColumnName X, Y, and Z to be the column names you want. If not, you should perhaps clarify your question with an example of a few rows worth of data.

您将ColumnName X,Y和Z更改为所需的列名称的位置。如果没有,您应该用几行数据的示例来澄清您的问题。