gpt4 book ai didi

php - MySQL 查询不返回任何内容或返回错误数据

转载 作者:行者123 更新时间:2023-11-29 12:32:36 25 4
gpt4 key购买 nike

我有两张 table 。 Table_1 有此字段。

table_1_id
name
image
adres

表_2

table_2_id
name
email
phone
comment
datetime
need_id

我想在点击 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

并显示空白页。然后我尝试了这样的

SELECT t1.*, t2.* FROM table_1 t1
JOIN table_2 t2 ON t1.table_1_id = t2.need_id ORDER BY ` DateTime` DESC

无论我点击什么,都会从数据库返回前 5 个结果,仅此而已。

最佳答案

假设您有 ID_1,则不需要在查询中涉及 table_1:

SELECT * FROM table_2
WHERE need_id = ID_1
ORDER BY `DateTime` DESC

关于php - MySQL 查询不返回任何内容或返回错误数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27252653/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com