gpt4 book ai didi

mysql 查询显示不正确的行

转载 作者:行者123 更新时间:2023-11-29 08:18:12 24 4
gpt4 key购买 nike

我有一个查询,当前应该只显示一行。然而,它以某种方式显示 4 行作为其结果集,即使 1) 表中只有三行开始 2) 只有一行与查询条件匹配。

我希望有人知道我在这个 MySql 查询中做错了什么

我的数据库表结构如下

smsid (int, auto increment), sms_type (text), sms_status (enum 'pending',sent'), sms_error (test), sms_message(text), sms_mp3file (varchar 50),sms_sendon (datetime), send_sms_toid (int 5)

My table entries are as so (following the order of the table columns above)

31 | mp3 | pending |  | | helloworld.mp3 | 2013-11-20 16:16:00 | 730 | text  | sent |  | hello test |  | 2013-11-18 13:12:00 | 8 29 | voice  | sent |  | testing 123 |  | 2013-11-18 10:05:00 | 18

My query is as below

SELECT sms_messages.*, sms_recipients.cust_profid, sms_recipients.sms_cellnumber, 
customer_smsnumbers.sms_number, customer_smsnumbers.sms_number
FROM sms_messages, sms_recipients, customer_smsnumbers
WHERE sms_messages.sms_type='mp3' AND sms_messages.sms_sendon <= '2013-11-21'
AND sms_messages.sms_status='pending' AND
sms_messages.send_sms_toid = sms_recipients.smsuser_id

最佳答案

在您的查询中,您错过了 customer_smsnumbers 表的 JOINING 子句。与 sms_messages.send_sms_toid = sms_recipients.smsuser_id 类似,您需要有一个连接子句,用于将 sms_messagescustomer_smsnumbers 表连接或连接 sms_recipients customer_smsnumbers 表。

如果没有连接子句,其他(非预期​​的)记录将包含在结果中。

关于mysql 查询显示不正确的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20137615/

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