Question

First yes it's going to be on a silly database that should most likely get remodeled. I'm not able to do that for a long list of reasons at this point.

I have a list of members and they have a trainer which is written in a first and last name (I know you're screaming FK, I just can't)

However a trainer has a username but at this point that's in php so I'm using a string for this example. I want to compare the first and last name without spaces. I believe this is called concatenation. But I can't get it to work and I am unsure as to why.

I have this so far. (MYSQL)

SELECT firstname,lastname 
FROM member
WHERE firstnameTrainer + lastnameTrainer LIKE 'jakethompson'
Was it helpful?

Solution

MySQL, ORACLE

SELECT firstname,lastname 
FROM member
WHERE CONCAT(firstnameTrainer,lastnameTrainer) LIKE 'jakethompson'

using LIKE 'jakethompson' means case insensitive

using LIKE '%jakethompson%' means anything what contains this string

OTHER TIPS

Use CONCAT:

SELECT firstname,lastname 
FROM member
WHERE CONCAT(firstnameTrainer,lastnameTrainer) LIKE '%jakethompson%'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top