List:General Discussion« Previous MessageNext Message »
From:bruce Date:July 4 2004 7:54pm
Subject:mysql sql question
View as plain text  
hi...

i have two hypothetical tables
create table owner (
    -> name char(20) ,
    -> ownerid int(10) auto_increment primary key);

create table dog (
    -> name char(20) ,
    -> ownerid int(10),
    -> dogid int(10) auto_increment primary key);

i'm curious as to how i'd go about inserting a name and the id of the owner,
in table "dog", in a single sql statement.

something like this psuedo sql..
 insert table (name, ownerid) values ($name, $ownerid)
   where owner.owner = owner

in other words, an app would supply the values for the "dog name", and the
"owner". the sql would be able to derive the "ownerid" for the "owner" from
the owner table, and then be able to insert the "ownerid", and "dogname"
into the dog table...

searching through google gets me to being able to write a php/perl script
where i can do this using multiple sql statements.. but i'm trying to see
how to do it in a single statement...

any comments/criticisms would be helpful...

thanks...

-bruce

Thread
date and time functions.Hari Yellina4 Jul
Re: date and time functions.Eric Bergen4 Jul
  • mysql sql questionbruce4 Jul
    • Re: mysql sql questionPaul DuBois4 Jul
      • RE: mysql sql questionbruce5 Jul
    • Re: mysql sql questionPeter Brawley6 Jul
RE: mysql sql questionbruce5 Jul
  • RE: mysql sql questionbruce5 Jul
RE: mysql sql questionQuentin Bennett5 Jul
  • RE: mysql sql questionbruce5 Jul
RE: mysql sql questionQuentin Bennett5 Jul
  • RE: mysql sql questionbruce5 Jul
    • mysql sql files...bruce5 Jul
      • RE: mysql sql files...bruce5 Jul
      • Re: mysql sql files...Paul DuBois5 Jul
    • Re: mysql sql questionJohn Hicks5 Jul
Re: mysql sql questionSGreen7 Jul