Page 3 of 3 FirstFirst 123
Results 21 to 26 of 26

Thread: HELP: insert data into 4 mysql tables

  1. #21
    Join Date
    Feb 2006
    Posts
    4,242
    Rep Power
    0

    Default

    That is what I had:
    PHP Code:
    $query mysql_query('SELECT * FROM name, address, phone, computer WHERE ( (name.id = address.id) AND (name.id = phone.id) AND (name.id = computer.id) ) ')or die (mysql_error()); 
    while (
    $result mysql_fetch_array($query)) 
        { 
                          
    //echo statements here to display records.
         

    I don't get any time as yet to research the INNER JOIN and implement it, problably you could quote the example 4 me, so that I get an idea for this;
    |--- www.RealJamaicaEstate.com ™ ---|
    Invest small = small returns [micro enterprise] | Invest Big = returns Big [macro enterprise]
    --- www.fashionsJAMAICA.com ™ -|- www.ChampsJamaica.com

  2. #22
    Join Date
    Dec 2002
    Posts
    500
    Rep Power
    0

    Default

    the query you entered would be equivalent to this join
    Code:
    SELECT	* 
    FROM	[name] inner join address 
    		on [name].[id] = address.[id]
    	inner join phone
    		on [name].[id] = phone.[id]
    	inner join computer 
    		on [name].[id] = computer.[id]
    -- WHERE [name].[id] = 007
    ... in SQL Server name and id are reserved so i put them in braces

    can you state the error message, if you are still getting one.
    Cultured in Aggression and Koding like a Warrior!!
    “Common sense is instinct. Enough of it is genius.” - George Bernard Shaw.
    "The significant problems we face cannot be solved by the same level of thinking that created them." - Albert Einstein

  3. #23
    Join Date
    Feb 2003
    Posts
    3,184
    Rep Power
    0

    Default

    @utech22 you need to run the insert queries separately, one after the other. preferably like this;
    Code:
    $query = "INSERT INTO computer (brand,type,..) VALUES ("Dell","Laptop",..)";  
    mysql_query($query);  
    if ( mysql_errno() | mysql_error() != '') {
       Die('<div>A Database Error has Occured : '. mysql_errno().": ".mysql_error()."</div>");	
    }
    
    $query = "INSERT INTO computer (brand,type,..) VALUES ("Dell","Laptop",..)";  
    mysql_query($query);  
    if ( mysql_errno() | mysql_error() != '') {
       Die('<div>A Database Error has Occured : '. mysql_errno().": ".mysql_error()."</div>");	
    }
    
    $query = "INSERT INTO computer (brand,type,..) VALUES ("Dell","Laptop",..)";  
    mysql_query($query);  
    if ( mysql_errno() | mysql_error() != '') {
       Die('<div>A Database Error has Occured : '. mysql_errno().": ".mysql_error()."</div>");	
    }
    get the point?

  4. #24
    Join Date
    Feb 2006
    Posts
    4,242
    Rep Power
    0

    Default

    I was thinking about that, but since I got the functionality, I did'nt bother to change it, but I do so now.

    I am googling and browsing the php manual to get the select with inner join;
    Some help still needed though.
    |--- www.RealJamaicaEstate.com ™ ---|
    Invest small = small returns [micro enterprise] | Invest Big = returns Big [macro enterprise]
    --- www.fashionsJAMAICA.com ™ -|- www.ChampsJamaica.com

  5. #25
    Join Date
    Feb 2003
    Posts
    3,184
    Rep Power
    0

    Default

    The php manual won't necessarily teach you to join. You have to read up on SQL queries. This wikipedia article seems general enough and should help you understand the concept;

    http://en.wikipedia.org/wiki/JOIN

  6. #26
    Join Date
    Apr 2003
    Posts
    13,269
    Rep Power
    34

    Default

    W3Schools is also a beginners place to start as well: http://www.w3schools.com/sql/default.asp

Posting Permissions

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