[EMAIL PROTECTED] wrote:
> 
> Hi,
> 
> Sorry for the possible offtopic question I'm going to ask.
> 
> I have got something similar (this is very simplicated situation of
> my problem but this is the core of my headache):
> 
> CREATE TABLE cityname (
>         id      BIGINT NOT NULL AUTO_INCREMENT,
>         cname   CHAR(50),
>         INDEX   id_index(id)
> );
> 
> CREATE TABLE firms (
>         id      BIGINT NOT NULL AUTO_INCREMENT,
>         fname   CHAR(50),
>         city0   BIGINT,
>         city1   BIGINT,
>         INDEX   id_index(id),
>         INDEX   city0_index(city0),
>         INDEX   city1_index(city1)
> );
> 
> Now I want to dump data out from my database with textual names of cities.
> if I do:
> 
> SELECT * FROM firms;
> 
> it's not good since I have to resolve the city names in further queries which
> seems to a bit expensive (inmagine that each record has got 6 cities.
> note that I had to use maximum of 6 cities so I don't want to create another
> table for the relation, but please ask me to this - and tell me how and why
> is it better - if it's better solution).
> 
> What can I do to have something similar result:
> 
> A+B company             Dallas          London
> New systems Ltd         New York        Paris
> 
> My knowledge in this situation is not enough for talking about mysql.
> Please help me, and CC the letter for me as well, since I'm not on any
> mysql mailing list.
> 
> Maybe my SQL knowledge is not too good as well to ask such a stupid question :)
> 
> By the way, where can I ask questions like this especially for MySQL? Maybe
> I should read some documents can be found on the net ... Tell URLs.
> Or whatever.
> 
>
I would suggest not having 2 cities in your firm record, and making
fname,city your key.

select * from firms order by fname,city would give you.
A+B company     Dallas
A+B company     London
New systems Ltd New York
New systems Ltd Paris

---------------------------------------------------------------------
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