如何编写SQL查询以将数据输入此数据库?

时间:2021-06-30 08:33:22

I've got a food menu which needs to have a pattern for when certain menus are displayed on a website.

我有一个食物菜单,需要有一个模式,以便在网站上显示某些菜单。

For example, the pattern is split into yearly quarters, weeks and days.

例如,模式分为年度,周和日。

**Quarter 1**
**Week 1**
Monday: 5
Tuesday: 4
Wednesday: 5
Thursday: 4
Friday: 6
Saturday: 7
Sunday: 7

The numbers represent the ID of the menu in the database.

数字表示数据库中菜单的ID。

So I have 4 quarters, 4 weeks and 7 days in the database. This is how it's laid out:

所以我在数据库中有4个季度,4周和7天。这就是它的布局:

如何编写SQL查询以将数据输入此数据库?

I don't get how to write the query to update the database, say for example I want to update the following:

我不知道如何编写查询来更新数据库,例如我想更新以下内容:

I want to put Menu Number: 4, In Week 1, Quarter 1 on a Thursday? That is based off what they select on a HTML Checklistbox.

我想把菜单编号:4,在第1周,第1季,周四?这是基于他们在HTML Checklistbox上选择的内容。

如何编写SQL查询以将数据输入此数据库?

2 个解决方案

#1


0  

For your example the query could be something like this.

对于您的示例,查询可能是这样的。

UPDATE menuset
SET thursday = 4
WHERE week = 1
AND quarter = 1

#2


0  

Something like this should work for you

这样的事情对你有用

update tablename SET monday=$monday WHERE week=$week AND quarter=$quarter

#1


0  

For your example the query could be something like this.

对于您的示例,查询可能是这样的。

UPDATE menuset
SET thursday = 4
WHERE week = 1
AND quarter = 1

#2


0  

Something like this should work for you

这样的事情对你有用

update tablename SET monday=$monday WHERE week=$week AND quarter=$quarter