1

is it possible to insert Values into two tables using inner join..? tables are user,details

user table contains user_id,name,passwrd

details table contain id,address,email

what i Did:

    if(isset($_POST['submit'])=='SUBMIT')
  {

       $user_name        =   $_POST['user_name'];
       $user_password    =   $_POST['user_password'];

       $details_email   =   $_POST['details_email']; 
       $details_phn      =   $_POST['details_phn'];
       $details_age     =   $_POST['details_age'];

 $SQL_QUERY="INSERT INTO tbl_user(user_name,user_password)VALUES('$user_name','$user_password')";
 $result=mysql_query($SQL_QUERY);

   $SQL_QUERY1="INSERT INTO tbl_details(details_email,details_phn,details_age)VALUES('$details_email','$details_phn','$details_age')";
 $result1=mysql_query($SQL_QUERY1);

   }

how can i rewrite with innerjoin...pls someone help me..

Strawberry
  • 33,750
  • 13
  • 40
  • 57
user2745897
  • 31
  • 1
  • 1
  • 8

1 Answers1

1

http://dev.mysql.com/doc/refman/5.0/en/join.html

MySQL supports the following JOIN syntaxes for the table_references part of SELECT statements and multiple-table DELETE and UPDATE statements:

You can't use join for INSERT. Sorry.

May I ask , what's the problem with 2 queries?

UPDATE Check @VolkerK 's comment, It offers alternative possible solutions: sql - insert into multiple tables in one query

Community
  • 1
  • 1
Ofir Baruch
  • 10,323
  • 2
  • 26
  • 39