gpt4 book ai didi

mysql - 如何忽略mysql中的重复行

转载 作者:行者123 更新时间:2023-11-29 17:01:14 26 4
gpt4 key购买 nike

我一直想通过使用来自多个表的联接来忽略重复值,但似乎我找不到自己的任何方法来做到这一点

我有三个 mysql 表

**tec_noti_send**
-------------
oid name
-------------
1 ali
2 ahmed
3 john
4 king

**tec_feedback_noti**
-------------
fid teacherreplied
-------------
1 TRUE
2 TRUE

**tec_query_noti**
-------------
tqid tqnoti_got_student
-------------
1 john smith
2 harry smith
3 suzane smith

我使用的查询

SELECT DISTINCT
tec_noti_send.*,
tec_feedback_noti.*,
tec_query_noti.*
FROM tec_noti_send
INNER JOIN tec_feedback_noti
INNER JOIN tec_query_noti

Result I want

 **join at once with no common column and auto incremented column**
-------------------------------------------------------
temorary
id name fid teacherreplied tqid tqnoti_got_student
--------------------------------------------------------
1 ali 1 TRUE 1 john smith
2 ahmed 2 TRUE 2 harry smith
3 john 3 suzane smith
4 king

最佳答案

您应该使用左连接

SELECT DISTINCT
tec_noti_send.*,
tec_feedback_noti.*,
tec_query_noti.*
FROM tec_noti_send
LEFT JOIN tec_feedback_noti on tec_noti_send.oid = tec_feedback_noti.fid
LEFT JOIN tec_query_noti on tec_noti_send.oid = tec_query_noti.tqid

关于mysql - 如何忽略mysql中的重复行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52236656/

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