Question: I have two tables one called customer\_sales and another distinct\_customers. 

This query returns the total number of sales per d\_id and customer number (but does not have the customer name)

```
select cs.d_id, cs.customer_number, cs.total_sales from cs_sales cs where cs.d_id = 'A00007';

```

This query returns the customer information (including name) from the d\_id

```
select  dc.c_name, dc.c_number, dc.d_name from dcust dc where d_id ='A00007';

```

I want to combine both queries so that I can get something like this

```
|-------|--------|-----------|-------------|
|d_id   | c_name |   d_name  | total_sales |
|-------|--------|-----------|-------------|

```

whats the best way to do this?
ive tried different ways and I keep on getting duplicate information back. 

Distinct\_customers sample data

[![enter image description here](https://i.stack.imgur.com/Y9Gif.png)](https://i.stack.imgur.com/Y9Gif.png)

customer\_sales sample data

[![enter image description here](https://i.stack.imgur.com/NpXl3.png)](https://i.stack.imgur.com/NpXl3.png)

Answer: 
I had the same issue, but using `mysql_native_password` was not possible with `PHP7.4-mysql-pdo`, even on setting in `my.cnf` as it worked on `PHP7.3-mysql-pdo`.

I had to alter **every user** with this query:

```
ALTER USER 'username'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'password';

```

where `username` is the database username and `password` is the password of the database user.
you can change the encryption of the password like this.

```
ALTER USER 'yourusername'@'localhost' IDENTIFIED WITH mysql_native_password BY 'youpassword';

```