user214577
user214577

Reputation: 363

SQL Enter parameter value

Im new to sql, Im writing a query to display the project numbers that have employees assigned to them.

SELECT PROJ_NUM
FROM project
WHERE EMP_NUM IS NOT null;

When i run the query I get asked to enter the parameter value for EMP_NUM. Why am i getting asked this?

Upvotes: 2

Views: 1671

Answers (1)

HansUp
HansUp

Reputation: 97101

Ordinarily that would suggest a spelling error, and that your project table doesn't include a field named EMP_NUM. However, if you've already confirmed that field does exist, perhaps the problem is due to the table name, project, which is a reserved word.

In that case, try your query like this ...

SELECT p.PROJ_NUM
FROM [project] AS p
WHERE p.EMP_NUM IS NOT null;

Postmortem: OP confirmed EMP_NUM does not exist in the project table. That is the reason the db engine interpreted it to be a parameter. The situation was confusing because with project open in Datasheet View, EMP_NUM was displayed in a subdatasheet of a related table. By examining his database relationships, OP was able to determine which table includes EMP_NUM and then INNER JOIN that table to project in his query.

Upvotes: 3

Related Questions