Search Posts

Category: mysql

How to database-side declare default high-precision datetime default + onupdate with mysql

I am trying to declare create_time and update_time with high-precision (milli/micro-second precision) in a MySQL db. The problem is that I cannot find the right syntax/functions to get those two requirements running. Assumptions/digging so far: I’ve found the only way for high precision datetime for MySQL to use mysql dialect DATETIME(fsp=6) (or TIMESTAMP(fsp=6)) I need to use argument server_default for database to set default I’m not sure how to set ON UPDATE NOW(6) Here is […]

Symfony Doctrine Relationships between 3 Tables

I am new with Symfony. I am working with version 3. I simplified my example. I have 3 Tables, for this tables I created a class for each one. Table “Person”: id | name Table “Group”: id | groupname Table “PersonGroup”: id | person | group Every Person could be in several groups and every groups can have several persons. In the table PersonGroup I connect the persons with the groups. In my Controller I […]

select the same day each month for the past 2 years or any year

i’m working on recurring payment monthly and i can’t or How do i select the same day each month for the past 2 years using SQL? example : send “23-11-2017” to get all records has been added in the same day or send “31-01-2018” to get all records has been added in the same day but all months don’t have same day “31” , how i can to get all records has been added in […]

MySQL Save Float Error

Try saving this number into any float or double field 588966.68 SQL query will do its thing and save the date and return success. Now retrieve the same value that you just saved, it will say 588966.69 You saved .68 and on read you get .69!!?! How is this possible? My field type is FLOAT(10,2) also tried with DOUBLE(12,2) with DECIMAL(12,2) and DECIMAL(12,3) although i need explicit 2 decimals only. I noticed this happening with […]

MySQL – Force DROP TABLE in EVENT without confirm

In MySQL phpmyadmin environment, when i create an event in which a DROP TABLE statement is set to occur, DROP TABLE (silently) does not occur, because my MySQL install, apparently, expects a confirmation. DROP EVENT IF EXISTS test.target_ultra_sync ; CREATE EVENT test.target_ultra_sync ON SCHEDULE EVERY 30 SECOND DO DROP TABLE IF EXISTS `test`.`ultra`; CREATE TABLE `test`.`ultra` AS SELECT * FROM `target_ultra`; The same occurs with TRUNCATE and DELETE. How can i suppress this behavior? Source: […]

Start a program (c# and mysql Database) simultaneous on several computers

I have to start a program on several computers at the same time (within ms). The program read out of and write into a mysql database. To ensure the simultaneous start, I thought about the sql dependency but does it also work for mysql? Are there any other ways to guarantee the synchronous start? It´s a project inside a laboratory. So it´s just a small network. Greetz Source: Stackoverflow

MySQL Query Grouping by Month

I have a MySQL query which outputs data like this: This is my current query that I’m using to generate the output. SELECT * FROM (SELECT staff.firstname AS stafffirstname , staff.surname AS staffsurname , , transactions.description , transactions.datetime , transactions.ID , (@runningtotal := @runningtotal + AS balance FROM transactions LEFT JOIN staff ON transactions.createdbyID = staff.ID WHERE transactions.tenancyID = ? ORDER BY transactions.datetime , transactions.ID) FullResults ORDER BY FullResults.datetime , FullResults.ID LIMIT ? […]

Image storing in mysql database with spring mvc and hibernate using ajax

I am trying to upload an image in mysql database using hibernate and spring ajax call is done in createImge.jsp page and controller is provided to handle the request where the image absolute path is stored in a variable and passed the entire entity object to daoImpl class where hibernate program is used to store in the database. I did not get any error but the thing is it is not inserted into the database […]

MySQL : How to join 2 select querys from the same table [duplicate]

This question already has an answer here: MySQL pivot table 8 answers I came across this problem and I didn’t find a solution! Consider this table payments: ———————————————- | id | theday | amount | currency | ———————————————- | 1 |16/12/2016| 300 | USD | | 2 |17/12/2016| 200 | USD | | 3 |16/12/2016| 100 | EUR | | 4 |17/12/2016| 400 | EUR | ———————————————- I want this output : —————————- | theday […]

Next Page »