简体   繁体   English

如何在 mysql 中使用 alter 和 select 仅显示表中的数据子集?

[英]How to only show a subset of data in a table by using alter and select in mysql?

I have a MySQL table like this:我有一个像这样的 MySQL 表:

TagName, DateTime, Value
'SG_QRA_SGTC_0013.PV_Top_Temp', '2022-07-05 11:27:43.7810000', '86.4'
'SG_QRA_SGTC_0013.PV_Bot_Temp', '2022-07-05 11:27:43.7030000', '25.1'
'SG_QRA_SGHAST_0065.PV_HUMIDITY', '2022-07-05 11:27:43.6890000', '85.11'
'SG_QRA_SGHAST_0066.PV_HUMIDITY', '2022-07-05 11:27:43.6890000', '38.48'

What I want to do is to to alter the table to only show this permanently but i am unable to do so now:我想要做的是更改表格以仅永久显示此内容,但我现在无法这样做:

TagName, DateTime, Value
'SG_QRA_SGTC_0013.PV_Top_Temp', '2022-07-05 11:27:43.7810000', '86.4'
'SG_QRA_SGTC_0013.PV_Bot_Temp', '2022-07-05 11:27:43.7030000', '25.1'

with this query:使用此查询:

SELECT * FROM testingintern WHERE TagName like '%Top%' OR TagName like '%Bot% AND TIME(DateTime) = '11:27:43';

Any help is appreciated thank you!感谢您提供任何帮助!

From the query you posted, the problem I see with it is that you forgot a ' after '%bot% , so it thinks you want something that contains %Bot% AND TIME(DateTime) = '11:27:43' instead of just %bot% .从您发布的查询中,我看到的问题是您在'%bot%之后忘记了一个 ',因此它认为您想要包含%Bot% AND TIME(DateTime) = '11:27:43'而不是只是%bot% Making it '%bot%' should fix or at least get you going in the right direction将其'%bot%'应该可以修复或至少让您朝着正确的方向前进

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM