Re: mysql_insert_id() and JOIN
| From: | Niel Archer | Date: | Sat, 11 Jul 2009 07:26:57 +0000 |
| Subject: | Re: mysql_insert_id() and JOIN | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-46270@lists.php.net to get a copy of this message | ||
> Hi again
>
> I dont understand how to use this two
>
> I read php.net and other sites, but dont understand...
http://dev.mysql.com/doc/
Available in the major languages, pick your filter and start reading.
Having documentation in your own language may help a lot towards
understanding.
> I have this four tables: table1, 2, 3 and 4
>
> So the SELECT is like this?:
>
> <?
>
> $query_select = "SELECT * FROM table1 FULL JOIN table2 FULL JOIN table3 FULL
> JOIN table4 ON table1.id=table2.id=table3.id=table4.id ORDER BY id ASC;
>
> mysql_query($query_select);
>
> ?>
>
> This is with FULL JOIN... How identificate the left table if I want to use
> LEFT JOIN?
The left table is the table to the left of the join. So:
SELECT id FROM table1 LEFT JOIN table2...
table1 is the left table and table2 is the right table (if you were to
use a RIGHT JOIN).
>
> How is the UPDATE?
>
> And the INSERT I dont understand yet how is it?
UPDATEs and INSERTs follow the same procedure.
When you INSERT an entry into the main table, you then use the function
mysql_insert_id() which will give you the value of the last 'id' column
generated, which you can then use to insert data into the secondary
tables.
>
> Im not to do a link between tables in PHPMyAdmin?
>
>
>
> Thank you very... VERY... much!
>
If you are using MySQL 4.1 or later you should use the mysqli extension
and not the older mysql one. UNLESS you are relying on the older style
passwords, which is a BAD idea.
--
Niel Archer