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
Hello
I didn't understand what results it is returned by that Select, and what result you want to get.
mlucicom
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
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
-
Random object from multiple arrays with percent chance in JS
JavaScript - jQuery - Ajax
First post
I have 3 arrays of objects in JavaScript:
const fruits =
const car =
const books =
One temporary array where I will store random objects...
Last post
You need to get two random numbers:
- the first to decide which group to pick,
- the second to pick an item from that.
We generate a random...
-
Multiple color-codes into color-names
JavaScript - jQuery - Ajax
First post
Plessant coursesweb,
I have a javascript what turns color-codes into color-names.
The problem is I have 20 results from color-codes, and I can...
Last post
Try use the following code:
<script>
const clr_codes = ;
var clr_rgb_name =[];
for(var i=0; i<clr_codes.length; i++){...