[quoted text, click to view] > The problem is that if i want to know the information about people
> with name "john"
>
> then i have to run many queries
This is the genisus of the problem. If you want to avoid the loops, you have
to select a single 'peopleid'
Then you can run simpler queries on the rest:
select *
from Address_Table
Where peopleid = ?
order by ?
select *
from phone_number_table
Where peopleid = ?
order by ?
I suspose you could also do:
select *
from Address_Table
Where peopleid in (select peopleid from people_table where name = 'john')
order by ?
select *
from phone_number_table
Where peopleid in (select peopleid from people_table where name = 'john')
order by ?
But you will have trouble ordering the output.
[quoted text, click to view] "Raan" <raan0101@gmail.com> wrote in message
news:1193019995.786628.241020@t8g2000prg.googlegroups.com...
> Hi All
>
> i have one query
>
> i have information about some people , these people have mulitple
> addresses(2-4) and multiiple phone numbers(3-10).
>
>
> I have created table like following
>
> people_table
> peopleid , name , age , profession , sex
>
>
> Address_table
> address_Id,peopleid , address
>
>
> phone_number_table
>
> phone_number_Id,
> peopleid , phone
>
>
> The problem is that if i want to know the information about people
> with name "john"
>
> then i have to run many queries
>
> first query is
> select peopleid , name , age from people_table;
>
> second query
> in loop according to the rslt obtained
> select address from Address_table where peopleId = ID_OBTAINED
>
> third query.. again in loop
> select address from phone_number_table where peopleId = ID_OBTAINED
>
> Is there any better for solving my problem. I think my db design or
> way of querying is poor.
>
>
> thnx
> Raan
>