Используя PHP и MySQL, я пытаюсь получить все отдельные значения из столбцов числа и типа из всех 4 таблиц, перечисленных ниже:
table_1
ID|t1_number|t1_type
1|1|new
2|1|old
3|2|new
4|3|new
5|1|old
table_2
ID|t2_number|t2_type
1|1|future
2|1|new
3|3|past
4|3|new
5|1|new
table_3
ID|t3_number|t3_type
1|1|past
2|1|new
3|1|new
4|1|new
5|1|old
table_4
ID|t4_number|t4_type
1|1|new
2|4|new
3|3|old
4|2|new
5|1|new
Значения, которые я хочу из приведенных выше таблиц будет:
числа: 1,2,3,4
типы: новое, старое, будущее, прошлое
Вот что у меня есть; но я не уверен, верен ли SQL или как отформатировать цикл while, чтобы получить значения.
$sql = "SELECT DISTINCT table_1.t1_number, table_2.t2_number, table_3.t3_number, table_4.t4_number, table_1.t1_type, table_2.t2_type, table_3.t3_type, table_4.t4_type
FROM table_1
JOIN table_2
JOIN table_3
JOIN table_4";
$result = @mysql_query($sql, $con) or die(mysql_error());
while($row = mysql_fetch_array($result)) {
$numbers= $row[?????????];
}