PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > subquery a city
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
subquery a city

Réponse
 
LinkBack Outils de la discussion
Vieux 24/10/2007, 09h06   #1
Bob Bedford
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut subquery a city

Hi all,

I've to link a person's address to the city table to know the state but
unfortunately the same ZIP may be in 2 different states (don't ask me
why....)

So I may have this in ZIP table:
ZIP CITYNAME STATE
1410 Thierrens VD
1410 Correvon VD
1410 Prevendavaux FR

So linking the city like this:
select STATE from person
left join city on person.ZIP = city.ZIP returns 2 rows.

I've tried to add a fulltext index in the city table and doing that

select STATE from person
left join city on (person.ZIP = city.ZIP and MATCH(city.city)
AGAINST(person.cityname))
isn't allowed as AGAINST need a string and can't work with a field name.

How can I fix this ?

Thanks for answering.

Bob


  Réponse avec citation
Vieux 24/10/2007, 10h21   #2
Captain Paralytic
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: subquery a city

On 24 Oct, 08:06, "Bob Bedford" <b...@bedford.com> wrote:
> Hi all,
>
> I've to link a person's address to the city table to know the state but
> unfortunately the same ZIP may be in 2 different states (don't ask me
> why....)
>
> So I may have this in ZIP table:
> ZIP CITYNAME STATE
> 1410 Thierrens VD
> 1410 Correvon VD
> 1410 Prevendavaux FR
>
> So linking the city like this:
> select STATE from person
> left join city on person.ZIP = city.ZIP returns 2 rows.
>
> I've tried to add a fulltext index in the city table and doing that
>
> select STATE from person
> left join city on (person.ZIP = city.ZIP and MATCH(city.city)
> AGAINST(person.cityname))
> isn't allowed as AGAINST need a string and can't work with a field name.
>
> How can I fix this ?
>
> Thanks for answering.
>
> Bob


Where the zip is in 2 different states, how do you decide which one
you want to choose?

  Réponse avec citation
Vieux 28/10/2007, 22h49   #3
Bob Bedford
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: subquery a city

"Captain Paralytic" <paul_lautman@yahoo.com> a écrit dans le message de
news: 1193214095.056186.152550@y27g2000pre.googlegroups. com...
> On 24 Oct, 08:06, "Bob Bedford" <b...@bedford.com> wrote:
>> Hi all,
>>
>> I've to link a person's address to the city table to know the state but
>> unfortunately the same ZIP may be in 2 different states (don't ask me
>> why....)
>>
>> So I may have this in ZIP table:
>> ZIP CITYNAME STATE
>> 1410 Thierrens VD
>> 1410 Correvon VD
>> 1410 Prevendavaux FR
>>
>> So linking the city like this:
>> select STATE from person
>> left join city on person.ZIP = city.ZIP returns 2 rows.
>>
>> I've tried to add a fulltext index in the city table and doing that
>>
>> select STATE from person
>> left join city on (person.ZIP = city.ZIP and MATCH(city.city)
>> AGAINST(person.cityname))
>> isn't allowed as AGAINST need a string and can't work with a field name.
>>
>> How can I fix this ?
>>
>> Thanks for answering.
>>
>> Bob

>
> Where the zip is in 2 different states, how do you decide which one
> you want to choose?

I've tried a match against but it doesn't accept a field in an other table
(it only allow a string parameter). So the best would be to return the first
one in the list as this value isn't so important. I'll later create a
function for letting choose the best value, but for now I need a value,
whatever the value is.
Or better, if I can decide like
coalesce((select state where zip = 1410 and Cityname = 'Correvon'),(select
state where zip = 1410))

In the first case returns the correct state (the one that has the correct 2
values (zip and cityname), and returns the first occurence if it doesn't
find the correct match for the first check.

It is possible, how ?


  Réponse avec citation
Vieux 29/10/2007, 00h05   #4
Paul Lautman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: subquery a city

Bob Bedford wrote:
> "Captain Paralytic" <paul_lautman@yahoo.com> a écrit dans le message
> de news: 1193214095.056186.152550@y27g2000pre.googlegroups. com...
>> On 24 Oct, 08:06, "Bob Bedford" <b...@bedford.com> wrote:
>>> Hi all,
>>>
>>> I've to link a person's address to the city table to know the state
>>> but unfortunately the same ZIP may be in 2 different states (don't
>>> ask me why....)
>>>
>>> So I may have this in ZIP table:
>>> ZIP CITYNAME STATE
>>> 1410 Thierrens VD
>>> 1410 Correvon VD
>>> 1410 Prevendavaux FR
>>>
>>> So linking the city like this:
>>> select STATE from person
>>> left join city on person.ZIP = city.ZIP returns 2 rows.
>>>
>>> I've tried to add a fulltext index in the city table and doing that
>>>
>>> select STATE from person
>>> left join city on (person.ZIP = city.ZIP and MATCH(city.city)
>>> AGAINST(person.cityname))
>>> isn't allowed as AGAINST need a string and can't work with a field
>>> name. How can I fix this ?
>>>
>>> Thanks for answering.
>>>
>>> Bob

>>
>> Where the zip is in 2 different states, how do you decide which one
>> you want to choose?

> I've tried a match against but it doesn't accept a field in an other
> table (it only allow a string parameter). So the best would be to
> return the first one in the list as this value isn't so important.
> I'll later create a function for letting choose the best value, but
> for now I need a value, whatever the value is.
> Or better, if I can decide like
> coalesce((select state where zip = 1410 and Cityname =
> 'Correvon'),(select state where zip = 1410))
>
> In the first case returns the correct state (the one that has the
> correct 2 values (zip and cityname), and returns the first occurence
> if it doesn't find the correct match for the first check.
>
> It is possible, how ?


I realise that English is not your first language. I'm afraid I really
cannot make any sense from what you have written above.

To make this easier, please supply a reasonable amout of sample data and the
expected results of the required query.


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 01h12.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12608 seconds with 12 queries