Skip to content

Comparing TIMEDIFF in MySQL

I have these following data: and the following query that I want to use to find all the entries where the timediff is lesser than 50 hours The second row should be returned because it’s lesser than 50 hours, but the first row, which the timediff is more than 50 hours keep returning as well. It returns a…

What is the difference between NOT and != operators in SQL?

What is the difference between NOT and != operators in SQL? I can’t understand the difference. I guess they are same. Answer NOT negates the following condition so it can be used with various operators. != is the non-standard alternative for the <> operator which means “not equal”. e.g…

Custom String Conversion

I want to convert a string that can have two formats. Example 1090512300 to 9.5.123 1090501300 to 9.5.13 The first string (1090512300) will always have the same length but the second(9.5.123) string won’t. The conversion logic is as follows 1 xx yy zzz 00 So string 1 will be 1xxyyzzz00 and string 2 xx.y…

insert if not exists in HQL

I am trying to write a query in HQL which can insert a record if it does not exists (with same name) so that there is no duplicate insertion when done from multiple threads. However, the record is not inserted. I suspect this is because the table is empty and the subquery returns 0 records despite the NOT EXI…

how to convert integer minutes to interval in postgres

I’m trying to convert minutes which are in integer to interval in postgres Is there any function that will help me to convert it to interval or should i have divide it by 60 and get the final result Answer Fastest way is with make_interval So it looks like this (as suggested by @Teddy) or, Not to say th…