distinct

mysql select distinct comma delimited values

房东的猫 提交于 2020-12-12 06:58:03
问题 i have a mysql table id cid c_name keywords 1 28 Stutgart BW,Mercedes,Porsche,Auto,Germany 2 34 Roma Sezar,A.S. Roma 3 28 München BMW,Oktober Fest,Auto,Germany i need a query to show keywords from cid=28 but i want to see only 1 time a keyword, like (BW,Mercedes,Porsche,Auto,Bmw,Oktober Fest,Germany) i dont want to list 2 time a keyword, how can resolve this problem? i have tried distinct but could not get what i want 回答1: Split it before adding it all up with DISTINCT.Of course,better is to

mysql select distinct comma delimited values

旧巷老猫 提交于 2020-12-12 06:57:53
问题 i have a mysql table id cid c_name keywords 1 28 Stutgart BW,Mercedes,Porsche,Auto,Germany 2 34 Roma Sezar,A.S. Roma 3 28 München BMW,Oktober Fest,Auto,Germany i need a query to show keywords from cid=28 but i want to see only 1 time a keyword, like (BW,Mercedes,Porsche,Auto,Bmw,Oktober Fest,Germany) i dont want to list 2 time a keyword, how can resolve this problem? i have tried distinct but could not get what i want 回答1: Split it before adding it all up with DISTINCT.Of course,better is to

SELECT DISTINCT with LEFT JOIN, ORDERed BY in t-SQL

穿精又带淫゛_ 提交于 2020-12-01 09:57:00
问题 I have the following table in SQL Server 2008: CREATE TABLE tbl (ID INT, dtIn DATETIME2, dtOut DATETIME2, Type INT) INSERT tbl VALUES (1, '05:00', '6:00', 1), (2, '05:00', '7:00', 1), (3, '05:01', '8:00', 1), (4, '05:00', '8:00', 1), (5, '05:00', '6:00', 2), (6, '05:00', '7:00', 2) that selects IDs of all records of the same type, with the same dtIn date, ordered by stOut in ascending order: SELECT DISTINCT tbl.id FROM tbl LEFT JOIN tbl AS t1 ON tbl.type = t1.type AND tbl.dtIn = t1.dtIn ORDER

SELECT DISTINCT with LEFT JOIN, ORDERed BY in t-SQL

馋奶兔 提交于 2020-12-01 09:54:14
问题 I have the following table in SQL Server 2008: CREATE TABLE tbl (ID INT, dtIn DATETIME2, dtOut DATETIME2, Type INT) INSERT tbl VALUES (1, '05:00', '6:00', 1), (2, '05:00', '7:00', 1), (3, '05:01', '8:00', 1), (4, '05:00', '8:00', 1), (5, '05:00', '6:00', 2), (6, '05:00', '7:00', 2) that selects IDs of all records of the same type, with the same dtIn date, ordered by stOut in ascending order: SELECT DISTINCT tbl.id FROM tbl LEFT JOIN tbl AS t1 ON tbl.type = t1.type AND tbl.dtIn = t1.dtIn ORDER

LINQ : Distinct and Orderby

扶醉桌前 提交于 2020-11-28 04:43:28
问题 I am trying to use LINQ (to EF) to get a DISTINCT list and then sort it. All the examples I found sort the result based on the DISTINCT value. But I want to sort it on a different field. Example: Table with 2 fields (canvasSize and canvasLength); var sizes = (from s in ent.competitors select s.canvasSize).Distinct().OrderBy(x => x); All the examples I found give this type of answer. But it sorts by canvasSize whereas, I want to sort by canvasLength. I'm stuck ... Any tips are greatly