whoami
whoami

Reputation: 27

How to select a column that has spaces with its name?

SELECT City, State
FROM PATIENT
WHERE [Patient Last Name] = 'Parker';

This is the code that I used to display city and state info for the patient whose last name is Parker. I tried [Patients Last Name], 'Patients Last Name', ['Patients Last Name'], WHERE [Patient Last Name] IN ('Parker') but neither of them worked. Are there any alternative ways?

Upvotes: 0

Views: 130

Answers (1)

Harun24hr
Harun24hr

Reputation: 36860

Try LIKE operator with wild card-

SELECT City, State
   FROM PATIENT
WHERE [Patient Last Name] LIKE '*Parker';

EDIT: After comment.

You table field name is LastName. So, try-

SELECT City, State FROM PATIENT WHERE [LastName] LIKE '*Parker';

Upvotes: 1

Related Questions