Table from a database (without duplicate items)

My database exemple:
| NAME | EMAIL | REGION | CITY | IDNUMBER |
| A | a@a.com | RegionA | X | 123 |
| A | b@b.com | RegionA | X | 123 |
| A | c@c.com | RegionA | X | 123 |
| B | x@x.com | RegionA | Y | 321 |
| B | y@y.com | RegionA | Y | 321 |
| C | h@h.com | RegionA | X | 456 |

And i Need this table as result:
| NAME | REGION | CITY |
| A | RegionA | X |
| B | RegionA | Y |
| C | RegionA | X |

but I have some duplicate rows in my database (ex.: some rows have the same name, but with diferent email in each row). The table is showing the duplicate rows, but i need to show these items just one time (not duplicated, as the exemple above). Sorry for my english. But thanks for the help.

Hi,

Take a look at the forum post Remove duplicates from connected dropdown options . You can use the parts of the code that removes duplicates and apply it to your table.

Good luck,

Yisrael

1 Like

Hello Yisrael. Thanks, but I already had tried it, and it return just a column. Take a look in my code:

wixData.query("Data")
  		.find()
  		.then((results) => {
		  	const uniqueIdNumber= getuniqueIdNumber(results.items);   
		  	$w("#table2").rows = buildRows(uniqueIdNumber); 
 		});
  	function getuniqueIdNumber(items) {    
    		const idNumberOnly = items.map(item => item.idnumber);
      		return [...new Set(idNumberOnly )];
      		
	}
	function buildRows(uniqueData) {   
		return uniqueData.map(curr => {
			return {"name": curr, "city": curr, "idnumber": curr};
		});
	}

My table appears like that:
| NAME | REGION | CITY |
| 123 | 123 | 123 |
| 321 | 321 | 321 |
| 456 | 456 | 456 |

Please, help me. I just need it to conclude my work. Thanks.

Hi, I was checking to see if you found a solution for this? I wrote a similar code and am trying to diagnose my issue.

Hi,
This is an old thread. Can you please post your question on a new thread and share with us the code you’ve written?

Thanks,
Tal.