Mysql select in multiple tables
Discuss coding issues, and scripts related to PHP and MySQL.
-
mlucicom
- Posts: 37
Mysql select in multiple tables
Hi! i have this database select query:
Code: Select all
// Interogare sql SELECT
$sql = "SELECT `location`.`id` , `location`.`location` , `location`.`customer` , `area`.`id` , `area`.`area` , `area`.`id_principal` , `area_description`.`id` , `area_description`.`description` , `area_description`.`id_area` , `area_images`.`id` , `area_images`.`patch`, `area_images`.`id_area`, `section`.`id_principal` , `section`.`id_principal` , `section`.`area_id` ,`section`.`section` , `section_description`.`description` , `section_description`.`id_principal` , `section_images`.`patch` , `section_images`.`id_principal`
FROM `location` , `area` , `area_images` , `area_description` , `section` , `section_description` , `section_images`
where `location`.`id`= `area`.`id_principal` AND `area_description`.`id_area` = `area`.`id` AND `area_images`.`id_area` = `area`.`id` AND `section`.`id_principal` = `location`.`id` AND `section_description`.`id_principal` = `location`.`id` AND `section_images`.`id_principal` = `location`.`id` ";
But if i have multiple record with same id in section_images i get this in different results.
Admin
Posts: 805
Hello
I didn't understand what results it is returned by that Select, and what result you want to get.
mlucicom
Posts: 37
I solve this..but i have any other question
If i have two column with same name in two different table and i foreach all results from database how can i make difference beetween this>
Admin
Posts: 805
You can add an Alias to the selected columns (with AS).
Code: Select all
$sql ="SELECT t1.id, t1.name AS namet1, t2.name AS namet2 FROM table1 AS t1, table2 AS t2";
- In php the results set will be with the name defined as alias. The array will have the keys: "id", "namet1", "namet2".
You can set any valid name as an alias.
Similar Topics
-
Multiple select for upload not working on mobile
JavaScript - jQuery - Ajax
First post
Plessant Coursesweb,
meight useless to ask but it seems this upload for picture-album is not working on my mobile-page
but on my computer I just...
Last post
Try to search on the internet for:
html multiple select upload mobile