SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How would i get something from mysql that requests something like this:

    Where ID=$id and ID=SubId

    I know it doesn't work, they are different tables but i would like to keep it to one wuery. How would i do this?

  2. #2
    SitePoint Evangelist
    Join Date
    May 2000
    Location
    Canada
    Posts
    533
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    both the ID's are from different tables ? ..

    i THINK you want LEFT JOIN ... not sure ... please elaborate on the exact situation
    cogito, ergo sum

  3. #3
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Never mind, I can't find an example, but when i do i will post it here.....

  4. #4
    SitePoint Guru
    Join Date
    Jan 2001
    Location
    Alkmaar, Netherlands
    Posts
    710
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I assume you have 2 tables and they have 1 to many relation.

    Person Table
    id integer
    name varchar(100)
    ...

    Task Table
    id integer
    personId integer
    task text
    ....

    To retrieve all tasks from the person with $id;
    SELECT person.name, task.text FROM person ,task WHERE person.id=task.personid AND person.id=$id


Bookmarks

Posting Permissions

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