MYSQL split date string to standard format - mysql

This is my first post on the forums.
I would like your help to have MySQL to convert from 20200416174119Z to 2020-04-16 17:41:19.
Thank you in advance for providing light to the world.
Best regards,

Well, after several for days of frustration, and failed attempts, here is a code that can help someone that is trying to do this
SELECT CONCAT(SUBSTR(date,1,4),'-',SUBSTR(date,5,2),'-',SUBSTR(date,7,2),' ',SUBSTR(date,9,2),':',SUBSTR(date,11,2),':',SUBSTR(date,13,2))

Related

SQL counting total by type

Hi everyone.
i have a question here that i was trying to practice on the web. however i do not know how write the MySQL query for this question. Can you please help me with this.
i keep getting errors in my codes. so far i only succeeded in concating the last name and first name together it seems.i do not know how to resolve the other parts of the questions
I hope you can help me with this

SQL Implementation - Social Media Like Functionality

I am building a full stack app, that is kind of like Pinterest or Instagram.
I've gotten stuck, which is a horrible feeling, and I'd love any help I could get from any kind soul out there! :)
So I'm trying to implement the "like" functionality. As y'all know, you can like an entity once, and only once. What I wonder is how to constrain the database in such a way that a user can't like more than once. The way I thought I'd do this is to have a separate Like table like this:
Now of course, if I UNIQUE the user_id, then users can only like one thing on the website, which obviously would be a disaster, hah. So my question is, how do I kind of make sure there are no duplicate rows with exactly the same information in them? Or make some kind of CHECK condition when creating the table so that there can't be more than one row where the user_id and the artpoem_id match?
Or am I thinking about this the wrong way? Should I have like a separate Like table for each and every ArtPoem-entry, and then UNIQUE the user_id?
I would be SO grateful for any help, as this has been bugging me for days. Thank you kindly!
Problem solved! If anyone else sees this in the future, here's how it happened:
With the help of #Solarflare here who pointed me in the right direction, I did this in my ORM (TypeOrm):
Which yielded this raw SQL:
And now my database gives me this error below when I try to add an additional like-table entry with matching artpoemIds and userIds, which is just what I was looking for! Yippie and onwards!

how to get different between specific time of 2 days in hours using mysql or php

i just need to get the different between specific time of 2 days in hours. so kindly let me know what is the possibility of it by using mysql.
T1= 2017-04-25 14:05:20
T2= 2017-04-28 17:20:10
so how can i get the value of T3 (T3=T2-T1) in hours using MySQL. If it is cant is there any possibility to use php?
TIMESTAMPDIFF function of MySQL will helps you.
SELECT TIMESTAMPDIFF(HOUR, '2017-04-25 14:05:20', '2017-04-28 17:20:10');
Hope this will helps you.

Database displays less records

I have a file with 4.300.000 records, but when I do SELECT COUNT(*) FROM 'mytable', It just displays 4.270.000. I don't know why is this happening, and I have no idea how to check what's going on. I've tried looking in Webmin, but I don't get it. Do you have any idea of how to see why is this failing?
Thank you and sorry for the bad English.

The sync principle of logstash-input-jdbc?

I want to know the sync principle of logstash-input-jdbc?
I know it is based on the time compare method like :
select
*
from
cc
where cc.modified_at > :sql_last_value,
Does it also based on database trigger methon.
When I grep the logstash-input-jdbc source, I find there is no any trigger information.
If you know, please help me.
Any help would be sincerely appreciate.