簡體   English   中英

MySQL查詢不返回任何東西或返回錯誤的數據

[英]MySQL query doesn't return anything or return wrong data

我有兩張桌子。 表_1具有此字段。

table_1_id
name
image
adres

TABLE_2

table_2_id
name
email
phone
comment
datetime
need_id

我想在單擊ID_1表格table_1table_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 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM