mysql 示列

福尔摩斯对我笑 2018-04-19 24236 次 11272条

该SQL语句可以实现如果存在该条数据就执行更新操作,如果不存在新增数据

INSERT INTO `m_keywords` (`keyword`, `date`)
VALUES
    ('seek', '2018-04-20') ON DUPLICATE KEY UPDATE count = count +1

if条件判断

SELECT
    *,
IF (
    C_CUSTOMER_CODING = NULL,
    C_CONTRACT_CODE,
    C_CUSTOMER_CODING
) AS total
FROM
    mid_order
WHERE
    MONTH (D_SYS_DATE) = MONTH ('2019-02-02')
AND YEAR (D_SYS_DATE) = YEAR ('2019-02-02')
and C_TWO_TYPE <> "订单"
GROUP BY
    total;

月份和年份的判断

AND YEAR(D_SIG_DATE) = YEAR ('${_this.dateArr[i]}')
month(D_SIG_DATE)= month('${_this.dateArr[i]}')

按最大合同号排重

let sql = `SELECT SQL_CALC_FOUND_ROWS Id,C_ONE_TYPE, C_CONTRACT_CODE, C_CUSTOMER_CODING,C_TER_CUSTOMER, month(D_SIG_DATE),
(Case
when C_ONE_TYPE="零金额订单" then ''
when C_CONTRACT_CODE like "N%" then ''
When C_TER_CUSTOMER='' Then C_CUSTOMER_CODING
WHEN C_TER_CUSTOMER IS NULL Then C_CUSTOMER_CODING
else C_TER_CUSTOMER
End
) As END_USER
FROM mid_order where Id = any(SELECT max(Id) FROM mid_order where month(D_SIG_DATE)= month('${_this.dateArr[i]}') GROUP BY C_CONTRACT_CODE ) AND YEAR(D_SIG_DATE) = YEAR ('${_this.dateArr[i]}')
GROUP BY END_USER;SELECT FOUND_ROWS() AS count`;
标签: 无

非特殊说明,本博所有文章均为博主原创。

下一篇
头像也是LOGO
未来博客 博主大人
到了这个年纪,不应该再彷徨!

发表评论



 


已有 11272 条评论 1


  1. HQ office installers

    I simply had to thank you so much yet again. I’m not certain what I might have made to happen without the actual tips provided by you concerning that area of interest. It became an absolute frustrating case for me personally, but spending time with a new professional technique you managed it took me to jump over fulfillment. Now i’m happier for your help and in addition trust you find out what a great job you are providing training most people thru a site. Most likely you haven’t come across any of us.

    回复 2019年12月7日
  2. Furniture assembly team

    Thanks for discussing your ideas right here. The other matter is that every time a problem develops with a laptop motherboard, individuals should not take the risk of repairing this themselves for if it is not done correctly it can lead to permanent damage to the entire laptop. Most commonly it is safe to approach any dealer of your laptop for that repair of its motherboard. They have got technicians that have an skills in dealing with notebook computer motherboard complications and can get the right diagnosis and undertake repairs.

    回复 2019年12月7日
  3. 스포츠중계

    Can I just say what a reduction to search out somebody who truly is aware of what theyre talking about on the internet. You positively know easy methods to deliver an issue to gentle and make it important. More individuals have to read this and perceive this facet of the story. I cant believe youre no more common because you positively have the gift.

    回复 2019年12月6日
  4. assemblers incorporated

    Somebody necessarily lend a hand to make critically posts I might state. That is the first time I frequented your website page and so far? I amazed with the research you made to create this particular publish incredible. Excellent job!

    回复 2019年12月6日
  5. 3d design

    you’re truly a good webmaster. The site loading velocity is incredible. It sort of feels that you are doing any distinctive trick. Moreover, The contents are masterwork. you’ve performed a great activity on this matter!

    回复 2019年12月6日
  6. udaipur call girls

    It is indeed my belief that mesothelioma can be the most lethal cancer. It contains unusual attributes. The more I actually look at it the harder I am sure it does not work like a real solid tissue cancer. In the event that mesothelioma is usually a rogue virus-like infection, so there is the potential for developing a vaccine and offering vaccination to asbestos exposed people who are vulnerable to high risk with developing foreseeable future asbestos associated malignancies. Thanks for giving your ideas for this important health issue.

    回复 2019年12月6日
  7. togel sgp

    Heya i’m for the primary time here. I found this board and I to find It really helpful & it helped me out a lot. I’m hoping to present one thing again and aid others like you helped me.

    回复 2019年12月6日
  8. moncler jackets

    I抎 should check with you here. Which is not one thing I usually do! I take pleasure in studying a post that may make individuals think. Also, thanks for permitting me to remark!

    回复 2019年12月5日
  9. i99bet

    You are so awesome! I don’t believe I’ve truly read anything like this before. So nice to find another person with some original thoughts on this subject. Really.. thank you for starting this up. This website is something that is required on the internet, someone with a bit of originality.

    回复 2019年12月4日
  10. i99bet

    Pretty! This has been an extremely wonderful article. Thanks for supplying this information.

    回复 2019年12月3日
  11. John Deere Technical Manuals

    Heya! I just wanted to ask if you ever have any issues with hackers? My last blog (wordpress) was hacked and I ended up losing a few months of hard work due to no back up. Do you have any methods to protect against hackers?

    回复 2019年12月2日
  12. air jordans

    There are some fascinating deadlines on this article but I don抰 know if I see all of them heart to heart. There’s some validity but I will take hold opinion until I look into it further. Good article , thanks and we want extra! Added to FeedBurner as nicely

    回复 2019年12月2日
  13. Britt Mantyla

    Greetings! Very useful advice in this particular post! It is the little changes that make the greatest changes. Many thanks for sharing!

    回复 2019年12月2日
  14. Tworzenie Stron Internetowych Gorzow

    of course like your web site but you have to take a look at the spelling on several of your posts. Several of them are rife with spelling problems and I to find it very bothersome to tell the reality nevertheless I’ll surely come again again.

    回复 2019年11月30日
  15. golden goose sneakers

    Can I simply say what a aid to seek out somebody who truly is aware of what theyre talking about on the internet. You positively know the best way to convey an issue to gentle and make it important. More folks must read this and perceive this facet of the story. I cant consider youre not more well-liked because you undoubtedly have the gift.

    回复 2019年11月30日
  16. Nannie Maclaren

    There are a couple of interesting points soon enough in this posting but I don’t determine if I see these center to heart. You can find some validity but Let me take hold opinion until I investigate it further. Good write-up , thanks so we want much more! Put into FeedBurner at the same time

    回复 2019年11月29日
  17. Quinton Backes

    When do you think this Real Estate market will go back up? Or is it still too early to tell? We are seeing a lot of housing foreclosures in Longwood Florida. What about you? We would love to get your feedback on this.

    回复 2019年11月28日
  18. jordan 6

    very nice put up, i actually love this web site, keep on it

    回复 2019年11月27日
  19. Read More Here

    I simply want to mention I’m all new to blogs and actually savored you’re blog site. Very likely I’m likely to bookmark your blog post . You actually come with impressive writings. Thank you for sharing your website page.

    回复 2019年11月24日
  20. curry 6

    I抦 impressed, I need to say. Really hardly ever do I encounter a blog that抯 each educative and entertaining, and let me inform you, you’ve got hit the nail on the head. Your idea is excellent; the difficulty is one thing that not sufficient people are speaking intelligently about. I’m very happy that I stumbled across this in my search for one thing regarding this.

    回复 2019年11月24日
  21. curry 6

    Hiya! I simply want to give a huge thumbs up for the great info you might have here on this post. I might be coming again to your blog for more soon.

    回复 2019年11月21日
  22. air max 2018

    I抎 should check with you here. Which isn’t one thing I normally do! I take pleasure in reading a post that may make individuals think. Additionally, thanks for allowing me to remark!

    回复 2019年11月18日