简体   繁体   中英

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:

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% . Making it '%bot%' should fix or at least get you going in the right direction

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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