我试着通过这种方式得到一个带有实际工作日名称的字符串:
Calendar c = Calendar.getInstance();
int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
if (c.get(Calendar.MONDAY) == dayOfWeek) weekDay = "monday";
else if (c.get(Calendar.TUESDAY) == dayOfWeek) weekDay = "tuesday";
else if (c.get(Calendar.WEDNESDAY) == dayOfWeek) weekDay = "wednesday";
else if (c.get(Calendar.THURSDAY) == dayOfWeek) weekDay = "thursday";
else if (c.get(Calendar.FRIDAY) == dayOfWeek) weekDay = "friday";
else if (c.get(Calendar.SATURDAY) == dayOfWeek) weekDay = "saturday";
else if (c.get(Calendar.SUNDAY) == dayOfWeek) weekDay = "sunday";
Run Code Online (Sandbox Code Playgroud)
但weekDay保持总是为空,我实际上不知道为什么因为调试器说dayOfWeek是5所以我应该等于c.get(Calendar.THURSDAY)
SELECT * FROM highscore ORDER BY score
Run Code Online (Sandbox Code Playgroud)
此代码总是将我的值排序为从最低到最高,但我希望它们从最高到最低.
实际上我的表中有两组数据,我总是得到:
0
235235
Run Code Online (Sandbox Code Playgroud)
但我需要它像这样:
235235
0
Run Code Online (Sandbox Code Playgroud)
我已经尝试过了:
SELECT * FROM highscore ORDER BY CAST(score AS int)
Run Code Online (Sandbox Code Playgroud)
但这给了我一个语法错误:
"您的SQL语法中有错误;请在第1行查看与您的MySQL服务器版本对应的手册,以便在'INT'附近使用正确的语法'"
在我的表中,得分设置为int(100).
有没有人有解决方案我怎么能这样排序呢?永远不会有负值或非int值.
如果我运行下面的 SQL 命令,我总是会收到此错误:
无效 SQL:CREATE TABLE ms_account (accountid INT NOT NULL auto_increment,accountname VARCHAR(50) NOT NULL,kindofaccount SMALLINT NOT NULL,accountowner VARCHAR(20) NOT NULL,accountcurrency VARCHAR(10) NOT NULL,accountbalance DECIMAL(15,2) NOT NULL,bankid VARCHAR(8) NOT NULL,createdate INT NOT NULL,deletedate INT NOT NULL,changedate INT NOT NULL,删除 SMALLINT NOT NULL,锁定 SMALLINT NOT NULL,PRIMARY KEY accountid (bankid,accountid)) ; :表定义不正确;只能有一个自动列,并且必须将其定义为键
SQL
"CREATE TABLE {$utcv_db_prefix}account (".
"accountid INT NOT NULL auto_increment,".
"accountname VARCHAR(50) NOT NULL,".
"kindofaccount SMALLINT NOT NULL,".
"accountowner VARCHAR(20) NOT NULL,".
"accountcurrency VARCHAR(10) NOT NULL,".
"accountbalance DECIMAL(15,2) NOT NULL,". …Run Code Online (Sandbox Code Playgroud)