auicsc
auicsc

Reputation: 297

Query results in empty result

I am trying the following query

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

the query runs successfully, But it returns no results although I have eid's that equal to some competence_id's and the where clause is also true

Actually,even without the where clause it does not work!

EDIT: Solved it by doing:

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

Upvotes: 0

Views: 89

Answers (2)

Saman Gholami
Saman Gholami

Reputation: 3512

Try this code :

select
 skillmgt.*, competences.Competence_Description
 from skillmgt,competences
where skillmgt.eid = competences.competence_id
...

Upvotes: 0

Denys Séguret
Denys Séguret

Reputation: 382514

datename returns a string. Depending on your SQL flavor, you should try

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

Upvotes: 2

Related Questions