name and surname in a single field

This is a discussion on name and surname in a single field within the MySQL Database forums, part of the Database Forums category; i have a database with a list of artists with a single field for the name and surname, separated with ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-04-2007
mcstanga
 
Posts: n/a
Default name and surname in a single field

i have a database with a list of artists with a single field for the
name and surname, separated with a space without the problem of the
composite surname (like de fonseca, because who insered the data used an
underscore to concatenate them, like de_fonseca)
now, i have to make an sql query ordered by surname, i'm using mysql and
asp.
how can i divide them?
i saw that the split function works well, i have to do:
splitted = split(namesurnamefield)
surname = splitted(ubound(splitted))
but how can i order the data with the ORDER_BY option?
is it possible?
can i make a virtual field like with DB2 on the AS400?
thanks,
Ale.
Reply With Quote
  #2 (permalink)  
Old 09-05-2007
subtenante
 
Posts: n/a
Default Re: name and surname in a single field

On Tue, 4 Sep 2007 20:32:40 +0200, alessandro.stanga@gmail.com
(mcstanga) wrote:

>i have a database with a list of artists with a single field for the
>name and surname, separated with a space without the problem of the
>composite surname (like de fonseca, because who insered the data used an
>underscore to concatenate them, like de_fonseca)
>now, i have to make an sql query ordered by surname, i'm using mysql and
>asp.
>how can i divide them?
>i saw that the split function works well, i have to do:
>splitted = split(namesurnamefield)
>surname = splitted(ubound(splitted))
>but how can i order the data with the ORDER_BY option?
>is it possible?
>can i make a virtual field like with DB2 on the AS400?
>thanks,
>Ale.


Are you sure it's also ok for the given names ? Like the french
Jean-Pierre may sometimes be written with a space instead of a hyphen.
If it is also replaced by _, then use something like :

SELECT SUBSTRING( name , LOCATE( name ,' ' ) ) AS surname
FROM ...
WHERE ...
ORDER BY surname
Reply With Quote
  #3 (permalink)  
Old 09-05-2007
mcstanga
 
Posts: n/a
Default Re: name and surname in a single field

On 5 Set, 11:24, subtenante <zzsubtenant...@gmail.com> wrote:
> Are you sure it's also ok for the given names ? Like the french
> Jean-Pierre may sometimes be written with a space instead of a hyphen.
> If it is also replaced by _, then use something like :


sure, replaced with _ too :)

> SELECT SUBSTRING( name , LOCATE( name ,' ' ) ) AS surname
> FROM ...
> WHERE ...
> ORDER BY surname


rs.open "select ARTISTA, SUBSTRING( ARTISTA, LOCATE( ARTISTA,' ' ) )
AS surname , ONLINE from artisti where ONLINE = 'S' ORDER BY surname
ASC" , conn

it ignores the ASC and DESC! why??
the records are always ordered by surname in inverted alphabetically
order.
thanks a lot!

Reply With Quote
  #4 (permalink)  
Old 09-05-2007
mcstanga
 
Posts: n/a
Default Re: name and surname in a single field

subtenante <zzsubtenantezz@gmail.com> wrote:

>
> SELECT SUBSTRING( name , LOCATE( name ,' ' ) ) AS surname
> FROM ...
> WHERE ...
> ORDER BY surname


another question.
can i divide the artists with the first character of theyyre surnames?
something like this:
where surname like a*
like b*
and so on.
i got an error, something that surname is a wrong column in the where
condition...
thank you for you support!
Reply With Quote
  #5 (permalink)  
Old 09-05-2007
Paul Lautman
 
Posts: n/a
Default Re: name and surname in a single field

mcstanga wrote:
> subtenante <zzsubtenantezz@gmail.com> wrote:
>
>>
>> SELECT SUBSTRING( name , LOCATE( name ,' ' ) ) AS surname
>> FROM ...
>> WHERE ...
>> ORDER BY surname

>
> another question.
> can i divide the artists with the first character of theyyre surnames?
> something like this:
> where surname like a*
> like b*
> and so on.
> i got an error, something that surname is a wrong column in the where
> condition...
> thank you for you support!


For "dynamic" columns you use the HAVING clause rather than the WHERE one


Reply With Quote
  #6 (permalink)  
Old 09-05-2007
mcstanga
 
Posts: n/a
Default Re: name and surname in a single field

Paul Lautman <paul.lautman@btinternet.com> wrote:

> For "dynamic" columns you use the HAVING clause rather than the WHERE one


i'm so noob!!
thanks!
Reply With Quote
  #7 (permalink)  
Old 09-06-2007
mcstanga
 
Posts: n/a
Default Re: name and surname in a single field

Paul Lautman <paul.lautman@btinternet.com> wrote:

> For "dynamic" columns you use the HAVING clause rather than the WHERE one


this doesn't work!
i can't get any record using surname like 'a*'
i've tried also '*a*' '%a%' but i still can't get any record.
strange as the order_by!
Reply With Quote
  #8 (permalink)  
Old 09-06-2007
Paul Lautman
 
Posts: n/a
Default Re: name and surname in a single field

mcstanga wrote:
> Paul Lautman <paul.lautman@btinternet.com> wrote:
>
>> For "dynamic" columns you use the HAVING clause rather than the
>> WHERE one

>
> this doesn't work!
> i can't get any record using surname like 'a*'
> i've tried also '*a*' '%a%' but i still can't get any record.
> strange as the order_by!


Could you reword this? I cannot understand what you are trying to say?


Reply With Quote
  #9 (permalink)  
Old 09-06-2007
mcstanga
 
Posts: n/a
Default Re: name and surname in a single field

Paul Lautman <paul.lautman@btinternet.com> wrote:

> Could you reword this? I cannot understand what you are trying to say?


i can't get any record using the having myfield like '*a'
the recordset remains empty but i'm pretty sure that there are a lot of
myfield that begin or ends with a.
Reply With Quote
  #10 (permalink)  
Old 09-06-2007
Paul Lautman
 
Posts: n/a
Default Re: name and surname in a single field

mcstanga wrote:
> Paul Lautman <paul.lautman@btinternet.com> wrote:
>
>> Could you reword this? I cannot understand what you are trying to
>> say?

>
> i can't get any record using the having myfield like '*a'
> the recordset remains empty but i'm pretty sure that there are a lot
> of myfield that begin or ends with a.


You may have to do a subquery for this one


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:51 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0