[英]MySQL query doesn't return anything or return wrong data
I have two tables. 我有两张桌子。 Table_1 have this fields.
表_1具有此字段。
table_1_id
name
image
adres
Table_2 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 我想在单击
ID_1
表格table_1
从table_2
加载所有具有table_1_id = 1
行,我已经尝试过使用此查询
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. 无论单击什么,这都是从数据库返回的前5个结果。
Assuming you have ID_1
, you don't need to involve table_1
in the query: 假设您具有
ID_1
,则无需在查询中包含table_1
:
SELECT * FROM table_2
WHERE need_id = ID_1
ORDER BY `DateTime` DESC
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.