On 5/23/06, Gary Wilson <[EMAIL PROTECTED]> wrote:
> Yes, I guess I could split the text entered and then do a search for
> each word in both first_name and last_name like the admin interface
> does... just seems like this would return many more results than wanted
> with a large user group.
It wouldn't return more results than desired; it would return exactly
the same results as if you'd queried for the derived field.
In other words, these two queries would return the exact same results:
SELECT * FROM foo WHERE first_name = 'Gary' AND last_name = 'Wilson';
SELECT * FROM foo WHERE (first_name || ' ' || last_name) = 'Gary Wilson';
You're best off searching by the exact fields rather than messing with
derived fields.
Come to think of it, this seems like a user-interface problem, not a
database problem. I'm assuming you want your users to be able to enter
a full name in a single text box, right? In that case, just split the
input by spaces and assume the first string is the first_name and the
second string is the last_name. (Of course, you'd want some error
correction in there to account for one- or three-word searches.)
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---