SQL isset 并且不显示空白“单元格”
我使用我的 MySQL 数据库表之一作为实际表,其中每一列都是一天中的时间,并且有一列称为日。你猜对了,在day中它表示星期几,在其余的单元格中它表示当时发生的事情。
我想做的只是显示其中有价值的单元格。就我而言,我总是将所有行和两列填满。这两列是“day”和“19:00”,但是将来我可能会添加“18:00”等的值。
那么,我如何才能只选择其中包含数据的列和行呢?某种类型的“哪里:有数据”?
谢谢!
编辑:图片
I'm using one of my MySQL database tables as an actual table, with times of the day as each column, and one column called day. You guessed it, in day it says the day of the week, and in the rest of the cells it says what is happening at that time.
What I want to do is only show the cells that have value in it. In my case, I'm always going to have all the rows and 2 columns full. The 2 columns are 'day' and '19:00', however in the future I might add values for '18:00' etc.
So, how can I only SELECT the columns and rows which have data in them? Some type of 'WHERE: there is data'?
Thanks!
EDIT: Picture
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将时间或日期作为列意味着您的字段名称中包含数据。数据属于表内部,因此您应该规范化数据库:
这样您就不会在表中获得大量空字段,并且不必更改数据库设计来添加一天中的另一个时间。
现在您可以轻松地仅获取存在的时间:
Having time or day as columns means that you have data in your field names. Data belongs inside the table, so you should normalise the database:
This way you don't get a lot of empty fields in the table, and you don't have to change the database design to add another time of day.
Now you can easily fetch only the times that exist:
根据我的收集,您正在寻找类似的内容,
但是如果您可以详细说明您的模式,特别是如果您可以绘制一个示例表,那将会很有帮助。
From what I gathere you are looking something along the lines of
But it would be helpful if you could elaborate more on your schema, especially if you could draw a sample table.