0

我正在尝试以下查询

`select
 skillmgt.*, competences.Competence_Description
 from skillmgt
 inner join competences
 on skillmgt.eid=competences.competence_id
 where eid=121 and datename(yyyy,timestamp)=2013`

查询成功运行,但它没有返回任何结果,尽管我的结果eid's等于 somecompetence_id's并且该where子句也是 true

实际上,即使没有该where子句,它也不起作用!

编辑:通过这样做解决了它:

 select skillmgt.*,competences.* from competences
 join skillmgt
 on competences.competence_id=skillmgt.cid
 where skillmgt.eid=121 and datename(yyyy,skillmgt.timestamp)='2013'
4

2 回答 2

2

datename返回一个字符串。根据您的 SQL 风格,您应该尝试

select
 skillmgt.*, competences.Competence_Description
 from skillmgt
 inner join competences
 on skillmgt.eid=competences.competence_id
 where eid=121 and datename(yyyy,timestamp)="2013"
于 2013-04-05T09:13:00.543 回答
0

试试这个代码:

select
 skillmgt.*, competences.Competence_Description
 from skillmgt,competences
where skillmgt.eid = competences.competence_id
...
于 2013-04-05T11:30:07.607 回答