Pergunta

I have a query here that doesn't work and having trouble pin pointing my mistake. Any help would be great. Thanks

I am trying to retrieve records with a program name starting with 'C' but my query returns zero records.

My PROGRAM table has an entry of a ProgName of Chemistry.

SELECT P.ProgNumber, ProgName, StudID, DateEnrolled
FROM PROGRAM AS P, STUDENT AS S
WHERE P.ProgNo = S.ProgNo
AND ProgName LIKE 'C%';
Foi útil?

Solução

Use

LIKE "C*"  

MSAccess doesn't use % as the wildcard

Outras dicas

SELECT 
    P.ProgNumber, P.ProgName, S.StudID, S.DateEnrolled
FROM 
    PROGRAM P
    JOIN STUDENT S ON S.ProgNo = P.ProgNo
WHERE 
    P.ProgName LIKE 'C%';

should work... you said you changed it to ='Chemistry', do you get the same result if you use lowercase c in chemistry?

You need to join the different tables like this...Try this...

SELECT P.ProgNumber, P.ProgName, S.StudID, S.DateEnrolled
FROM PROGRAM P
JOIN STUDENT S
ON P.ProgNo = S.ProgNo
WHERE P.ProgName LIKE 'C*'; -- Asterisk because its Access not MS-SQL
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top