Jump to content

How to find a specific character in a result.


JSHINER

Recommended Posts

I am using this:

 

"SELECT vendors.name, SUBSTRING_INDEX(vendors.name, ' ', -1) AS lastname"

 

Which will take "Smith" out of John Smith or "Anderson" out of Mike J. Anserson.

 

Now how can I also create a lastname_alpha to get S or A (just the first character out of the lastname.

 

Also another question...

 

when I set that to lastname, and try to call that lastname in the WHERE clause I get the error:

 

Error: Unknown column 'lastname' in 'where clause'

 

What I want is if I use "page.php?last=Smith - I want it to find records where lastname = Smith based on the lastname created above. I am trying:

 

WHERE lastname = $last

 

What am I doing wrong here?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.