I have two tables. Table_1 have this fields.
table_1_id
name
image
adres
Table_2
table_2_id
name
email
phone
comment
datetime
need_id
I want to make when I click on the ID_1
form table_1
to load me all rows from table_2
which have table_1_id = 1
I've tried with this query
SELECT t1*, t2.* FROM table_1 t1, table_2 t2
WHERE t1.table_1_id = t2.need_id ORDER BY `DateTime` DESC
and show blank page. Then I tried like this
SELECT t1.*, t2.* FROM table_1 t1
JOIN table_2 t2 ON t1.table_1_id = t2.need_id ORDER BY ` DateTime` DESC
This whatever I click is returned first 5 results from database and that's it.
Assuming you have ID_1
, you don't need to involve table_1
in the query:
SELECT * FROM table_2
WHERE need_id = ID_1
ORDER BY `DateTime` DESC
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.