gpt4 book ai didi

mysql - 如何使用 Like 运算符在 Mysql 中不显示重复值?

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

这是我正在使用的 mysql 查询。

SELECT distinct Emprego.title as title, Emprego.up as up, Emprego.datetime as datetime, Emprego.content as content, Category.name as category_name, Emprego.states as states, Emprego.id as id, User.nome as nome, Emprego.email as email FROM City, User , Category, Emprego, Type
where
Emprego.category_id=Category.id and Emprego.City_id=City.id and Emprego.type_id=Type.id and Type.id='$type'
and (Emprego.title LIKE '%$text%') or (Emprego.content like '%$text%') and Emprego.User_id= User.id
order by datetime DESC

我通过此查询得到了重复的行。

怎么解决???

这是结果:

[
{
"title": "Cozinheiro Madeira",
"up": "1",
"datetime": "2017-09-05 23:41:48",
"content": "Cozinheiro na \nMadeira",
"category_name": "Telecomunicações",
"states": "2",
"id": "12",
"nome": "admin",
"email": "admin@getal.con"
},
{
"title": "Cozinheiro Madeira",
"up": "1",
"datetime": "2017-09-05 23:41:48",
"content": "Cozinheiro na \r\nMadeira",
"category_name": "Telecomunicações",
"states": "2",
"id": "16",
"nome": "admin",
"email": "admin@getal.con"
}
]

最佳答案

您可能因以下原因而遇到问题:

(Emprego.title LIKE '%$text%') or (Emprego.content = '%$text%') and Emprego.User_id= User.id

您的意思是:

(Emprego.title LIKE '%$text%' or Emprego.content = '%$text%') and Emprego.User_id= User.id

关于mysql - 如何使用 Like 运算符在 Mysql 中不显示重复值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46065544/

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