Try:

SELECT * FROM Students 
WHERE CONCAT(LastName, ', ', FirstName) LIKE 'Smith, J%'

or 

SELECT * FROM Students 
WHERE CONCAT(LastName, ', ', SUBSTRING(FirstName,1,1))='Smith, J'


On Tue, 2003-01-07 at 15:37, Lefevre, Steven wrote:
> I'm developing a web-site database. There is a form on one page where a user
> can search for a student by typing in a last name and submitting it.
> 
> Sometimes there can be more than one student with the same last name, so I
> want the user to be able to type in "Smith, J" (where normally they type
> 'Smith').
> 
> The problem (as I see it) is that I'm storing the last name and the first
> name in two seperate fields. I can make an SQL statement like "Select * from
> Students Where LastName Like "Smith%";", but can I make something like
> 
> "SELECT * FROM Students WHERE (LastName, ", ", FirstName) AS Name LIKE
> "Smith, J%";"
> ?
-- 
Diana Soares


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to