我希望两个房间的两个日期之间的结果可用房间。
我的查询
CREATE TABLE AccountTable
(
RowID int IDENTITY(1, 1),
AccountID varchar(2),
AccountName varchar(50),
SeqNum int,
SeqDate datetime
)
public class dbvalue
{
public int db_value { get;set; }
}
//OnClick Method
cmd.CommandText ="SELECT SeqNum FROM AccountTable;";
int i = Int32.Parse(amount.Text);
SqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
int k(int)sdr["SeqNum"];
foreach(List item in CheckBoxList1.Items)
{
for(int n = k; n <= i; n++)
{
if (item.Selected)
{
System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image();
string barcode_label = item.Text + "QTY:___________"
string barode_data = item.Value + datepicker.Text + n.ToSTring("D2");
Bitmap dynImage = DrawBarcode(barcode_data, barcode_label)
MemoryStream ms = new MemoryStream();
dynImage.Save(ms, ImageFormat.Jpeg);
byte[] byteImage = ms.ToArray();
Convert.ToBase64String(byteImage);
img.ImageUrl = "data:image/jpeg;base64," + Convert.ToBase64String(byteImage);
panel1.Controls.Add(img);
double spacing;
double mg = 5;
spacing = img.Width.Value + mg;
}
}
}
}
此查询未显示任何结果。
SELECT *
FROM `roomcalendar`
WHERE day BETWEEN '2016-08-29' and '2016-08-31'
我可以使用roomname =&#39; Room-A&#39;但我不想用它。使用房间名称在两个日期之间获得两个可用房间的任何其他方法?
答案 0 :(得分:0)
SELECT *
FROM `roomcalendar` r
WHERE DAY BETWEEN '2016-08-29' AND '2016-08-31' AND r.`avaroom`>0
ORDER BY r.`day`
答案 1 :(得分:0)
如果我正确理解你的问题,你需要的东西可能是:
SELECT r.roomname, SUM(r.avaroom) as availableRooms
FROM roomcalendar r
WHERE DAY BETWEEN '2016-08-29' AND '2016-08-31'
GROUP BY r.roomname
我会给你:
+----------+----------------+
| roomname | availableRooms |
+----------+----------------+
| Room-A | 5 |
| Room-B | 4 |
+----------+----------------+
这是你想要的吗?