Я хочу сделать запрос MySQL, который выбирает информацию обо всех пользователях (имя, возраст, мобильный телефон и т. Д.), За исключением дубликатов на «электронной почте» или «мобильном телефоне».
Итак, я хочу избежать отображения повторяющихся записей для пользователей, которые зарегистрировались более одного раза.
Мой запрос:
$sql = "SELECT tet.id tet_id, tet.firstName tet_fristName, tet.lastName tet_lastName,tet.image tet_image,
tet.url tet_url,tet.address tet_address,tet.job tet_job,tet.age tet_age,
tet.mobilePhone tet_mobilePhone, tet.homePhone tet_homePhone, tet.email tet_email,
tet.date_of_registration tet_date_of_registration, tet.player_id tet_player_id,
app.value app_value, app.date app_date
FROM `test_players` as tet
LEFT JOIN approved_test_players as app on app.player_id=tet.id WHERE app.value IS NULL order by tet.id desc ";
$result = $conn->query($sql);
SELECT DISTINCT tet.firstName as tet_fristName, tet.lastName as tet_lastName,tet.age as tet_age, tet.mobilePhone as tet_mobilePhone, tet.email as tet_email
FROM `test_players` as tet
JOIN approved_test_players as app
ON app.player_id=tet.id
WHERE app.value IS NULL
order by tet.id desc
Попробуй это
Select id
From table group by tel
Having count(user_id)>2