mysql abfrage über 3 tabellen problem

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • mysql abfrage über 3 tabellen problem

    hi,

    habe mich schon durch diverse turtorials geplagt, krieg das aber einfach nicht gebacken.

    ich habe drei tabellen:

    table member_person:
    id int not null auto_increment primary key,
    name varchar(30) not null,
    job varchar(30) not null,
    city varchar(30) not null,
    birthday varchar(30) not null,
    status varchar(20) not null,
    hobbys varchar(120) not null,
    previousCars varchar(250) not null,
    urlImgPerson varchar(120) not null,
    datetime timestamp,
    visible tinyint(4) not null default '0'

    table member_car:
    id int not null auto_increment primary key,
    uid int not null,
    brand varchar(30) not null,
    build varchar(30) not null,
    color varchar(30) not null,
    hp varchar(50) not null,
    additions varchar(50) not null,
    urlImgCar varchar(120) not null,
    datetime timestamp,
    visible tinyint(4) not null default '0'

    table uped_img:
    id int not null primary key auto_increment,
    uid int not null,
    mark varchar(120) not null,
    url varchar(120) not null

    hier möchte ich nun folgendes abfragen:

    SELECT member_person.id, member_person.name, member_person.city, member_person.memberSince, member_person.birthday, member_person.status,
    member_car.brand, member_car.build, member_car.hp, member_car.color, UNIX_TIMESTAMP(member_person.datetime) AS datetime FROM member_person, member_car
    WHERE member_car.visible > -1 AND member_person.visible > -1 AND member_person.id = member_car.uid;

    das geht soweit auch, aber wenn ich jetzt noch

    uped_img.url, uped_img.mark

    von der dritten tabelle haben möchte funktioniert das nicht, kann mir da jemand einen tip geben, bitte habt gedult bin in sachen mysql anfänger.

    ps.: habs auch schon mit diversen joins probiert, bekomms aber auch damit nicht hin.

  • #2
    PHP-Code:
    SELECT 
     member_person
    .id,  
     
    member_person.name
     
    member_person.city
     
    member_person.memberSince
     
    member_person.birthday
     
    member_person.status
     
    member_car.brand,  
     
    member_car.build
     
    member_car.hp
     
    member_car.color
     
    UNIX_TIMESTAMP(member_person.datetime) AS datetime,
     
    uped_img.url
     
    uped_img.mark
    FROM 
     member_person

     
    member_car,
     
    uped_img
    WHERE 
     member_car
    .visible > -AND 
     
    member_person.visible > -AND 
     
    member_person.id member_car.uid AND
     
    uped_img.uid member_person.id 

    Kommentar


    • #3
      funzt, vielen dank krel!

      Kommentar


      • #4
        wichtig ist, dass du verstehst wieso es jetzt funktioniert

        Kommentar

        Lädt...
        X