• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Quick and easy SQL question

LostHiWay

Golden Member
I'm trying to find all employees who have a letter a in their name. I have no problem if they asked if it started with an A or ended with an A, Ijust can't figure out how to find if a name has an a without knowing the postion. So far...

select employee_name
from emp
where employee_name ???????

Any help?? I'm sure it's simple
 
Originally posted by: Mitzi
select employee_name
from emp
where upper(employee_name) like '%A%'

Should do it.


wouldn't that just give me the employees with a letter A between the first and last letters in their name? What if their name started with a 'A' but had no other A's?

Or am I just thinking wrong?
 
Originally posted by: MrChad
No, the LIKE operator uses the % character as a wild card. A % can represent one or more characters.

For it to work the way he wants wouldn't it actually have to to represent 0 or more characters?
 
Originally posted by: jonmullen
Originally posted by: MrChad
No, the LIKE operator uses the % character as a wild card. A % can represent one or more characters.

For it to work the way he wants wouldn't it actually have to to represent 0 or more characters?

You are correct, and I was mistaken in my previous post. A % can represent zero or more characters. 😱
 
As a quick note, MySQL is case INSENSITIVE with LIKE searches, so you don't need the UPPER() call if it's MySQL.

PostgreSQL has an ILIKE ( case INSENSITIVE LIKE ) too, which might help if you're using PostgreSQL.
 
Originally posted by: Superwormy
As a quick note, MySQL is case INSENSITIVE with LIKE searches, so you don't need the UPPER() call if it's MySQL.

PostgreSQL has an ILIKE ( case INSENSITIVE LIKE ) too, which might help if you're using PostgreSQL.

Ahh apologies, I didn't know that, we use Oracle here 🙂

 
Back
Top