R
R
run1822016-02-05 13:12:30
MySQL
run182, 2016-02-05 13:12:30

MySQL How to select terms for which two fields are not equal to each other?

There is a table with fields:
id, email, type, type_2
You need to select those rows in which the fields type и type_2do not have the same value.
Here is the complete code:

SELECT `b2`.`NAME` as `a_name`,`b2`.`LAST_NAME` as `a_last_name`,`b2`.`LOGIN` as `a_login`,`b1_d`.`UF_VK_PROFILE`,`b1_d`.`UF_FB_PROFILE`,`b1_d`.`UF_GP_PROFILE`,`kpi_amplifier`.*,
  `b1`.`PERSONAL_BIRTHDAY` as `u_birth_date`,`b1`.`PERSONAL_PHONE` as `u_phone_1`,`b1`.`PERSONAL_MOBILE` as `u_phone_2`,`b1`.`NAME` as `u_name`,`b1`.`LAST_NAME` as `u_last_name`,`b1`.`EMAIL` as `u_email`,`b1`.`LOGIN` as `u_login` 	
  FROM `kpi_amplifier` 
  RIGHT JOIN `b_user` as `b1` ON `b1`.`ID`=`kpi_amplifier`.`UF_USER` 
  RIGHT JOIN `b_uts_user` as `b1_d` ON `b1`.`ID`=`b1_d`.`VALUE_ID` 
  RIGHT JOIN `b_user` as `b2` ON `b2`.`ID`=`kpi_amplifier`.`UF_AMPLIFIER` 
  RIGHT JOIN `b_user_group` ON `b_user_group`.`USER_ID`=`kpi_amplifier`.`UF_AMPLIFIER` 
  WHERE `b_user_group`.`GROUP_ID`=8 AND (`kpi_amplifier`.`UF_EVENT`>0 OR (`kpi_amplifier`.`UF_ACTION_TEXT`='change_status' AND 
`kpi_amplifier`.`UF_TYPE`<>`kpi_amplifier`.`UF_TYPE_2`)) 
  AND `UF_DATE_TIME` >='YYYY-MM-DD' AND `UF_DATE_TIME`<='YYYY-MM-DD' 
  ORDER BY `ID` desc LIMIT 0,10000

I mean fields
`kpi_amplifier`.`UF_TYPE`<>`kpi_amplifier`.`UF_TYPE_2`

I tried to make a selection, you can see in the code, but the result is not the same

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Peter, 2016-02-05
@petermzg

select * from table where type != type_2

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question