mysql中有distinct吗,mysql中的distinct不起作用。

Hi friends,

In my MySQL query distinct is not working properly.I am getting duplicate records at the time of retrieving records.

code:SELECT DISTINCT slip_header_trn.slip_no, slip_header_trn.com_cd, slip_header_trn.cust_cd, slip_header_trn.entry_div, slip_header_trn.dest_cd, slip_header_trn.est_date,slip_header_trn.entry_date,slip_header_trn.order_date,slip_header_trn.delivery_comp_date, slip_header_trn.status_cd, slip_details_trn.model_cd, slip_details_trn.item_cd, model_mst.model_nm, destination_mst.dest_name, customer_mst.cust_nm, user_mst.user_nm, supplier_mst.sup_nm, company_mst.com_name FROM slip_header_trn LEFT OUTER JOIN slip_details_trn ON slip_header_trn.slip_no = slip_details_trn.slip_no LEFT OUTER JOIN customer_mst ON slip_header_trn.cust_cd = customer_mst.cust_cd LEFT OUTER JOIN destination_mst ON slip_header_trn.dest_cd = destination_mst.dest_cd LEFT OUTER JOIN supplier_mst ON slip_details_trn.sup_cd = supplier_mst.sup_cd LEFT OUTER JOIN user_mst ON slip_header_trn.user_id = user_mst.user_id LEFT OUTER JOIN model_mst ON slip_details_trn.model_cd = model_mst.model_cd LEFT OUTER JOIN company_mst ON slip_header_trn.com_cd = company_mst.com_cd WHERE slip_header_trn.del_flg = 0

解决方案Hi,

According to my knowledge on DISTINCT usage, for better and indeed distinct results you have to "Project One Column" on your table!

You are giving your database alot of work/overhead to try and perform a distinct search on more 10 columns as per query posted. It''s good practice to sometimes target integer, char columns or columns with less data.

Just imagine if your boss asked you to code in more than 10 languages at the same time? you may ofcourse know more than 10 languages but your performance will drop-dead and the results may be not as expected - exactly why you are still getting duplicate rows in your query that is using DISTINCT! coz it''s just as confused as u would be...

Good luck.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值