Results 1 to 2 of 2

Thread: complex query

  1. #1
    Join Date
    Nov 2003
    Posts
    1

    Unanswered: complex query

    Hello Guys,

    I have a query :

    select id,name,address
    from
    (select * from
    (select id,name,address from call)
    union all
    (select id,name,address from call2)
    )

    it gives me for example 3 records from table call and call2 :
    1 jack USA
    2 tom USA
    4 harry canada

    I have another table subscription containing the coloums : name, subscription_type containing the data:

    jack prepaid
    tom postpaid
    harry normal

    I want to modify the query so that I get the id,name,address from call and call2 and subsription_type from subscriber table for the name 'jack'
    The results sshould be like this : 1 jack USA prepaid

    Thanks in advance

    Smith

  2. #2
    Join Date
    Nov 2002
    Location
    Desk, slightly south of keyboard
    Posts
    697
    Hi,

    I'm not quite sure I'd call that a complex query, but this may help

    PHP Code:
    select ppl.idppl.nameppl.addresssubs.subscription_type
    from  
    (
          
    select id,name,address from call
          union all
          select id
    name,address from call2
          
    ppl,
          
    subscription subs
    where subs
    .name ppl.name 
    You could construct it in a number of different ways.

    Hth
    Bill

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •