Category: MySQL

typeorm: force mysql2 if mysql is installed

Query asked by user I know this is a special use case, but I have both mysql and mysql2 packages installed and I need to test both of them. However as my understanding typeorm will first check if mysql is in the node_modules and use it. How can I force mysql2 to be used instead? […]

General error: could not call class constructor’

Query asked by user I’m just trying to make operation which looks pretty simple but getting a strange error Uncaught exception: ‘PDOException’ Message: ‘SQLSTATE[HY000]: General error: could not call class constructor’ Stack trace: 0 C:\xampp\htdocs\hotel\Core\Model.php(48): PDOStatement->fetch() 1 C:\xampp\htdocs\hotel\App\Controllers\Admin\Rooms.php(188): Core\Model::findById(’98’)*** 2 C:\xampp\htdocs\hotel\Core\Router.php(78): App\Controllers\Admin\Rooms::deletePhoto() 3 C:\xampp\htdocs\hotel\public\index.php(62): Core\Router->dispatch(‘admin/rooms/del…’) 4 {main}** Thrown in ‘C:\xampp\htdocs\hotel\Core\Model.php’ on line 48 This is […]

Adding rewriterule to htaccess ignores JavaScript

Query asked by user I have added htaccess rewrite rule to make the link easier to remember or just to look better, for example, everything works on http://localhost/moviescat.php?id=Action but nothing works on http://localhost/movies/genre/Action Here is my code for it: Options -Multiviews # Mod Rewrite Options +FollowSymLinks RewriteEngine On RewriteBase / ErrorDocument 404 /404.php RewriteCond %{REQUEST_FILENAME} […]

Sequelize can’t create table but when I run the same in MySQL CLI it works

Query asked by user I am using sequelize and have run into a weird error: Executing (default): CREATE TABLE IF NOT EXISTS `groups` (`id` INTEGER NOT NULL auto_increment , `groupname` VARCHAR(255), `groupkey` VARCHAR(255), `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB; Executing (default): CREATE TABLE IF NOT EXISTS `users` (`id` INTEGER […]

MySQL How to SELECT where field equals something in another table?

Query asked by user Take two example tables: TableOne +—-+———-+————-+————+————+–+ | id | uid | thingone | thingtwo | thingthree | | +—-+———-+————-+————+————+–+ | 1 | 7 | 0 | 1 | 1 | | | 2 | 8 | 1 | 1 | 0 | | +—-+———-+————-+————+————+–+ and TableTwo +—-+———-+————-+————+————+–+ | id | oid […]

How to check different mysql tables and get output

Query asked by user I have retrieved following data from allbook table, Book Name copies Book1 5 Book2 6 Book3 7 Book4 8 Further I have another table,issuedbooks which I issued those books to some students. Student BookName Issued Date Ann Book1 5/20/2022 Mike Book1 5/21/2022 Micheal Book2 5/22/2022 John Book3 5/23/2022 Now I need […]

How to join tables without using join sql

Query asked by user Hi im trying to solve a sql querey where I need to grab information from multiple tables and output the end result. A list of all clients that have not placed a stock request yet. Displaying client number will be sufficient. I am not allowed to use inner join or any […]

Row values should be one by one in MySQL

Query asked by user I’m stuck in a particular point of MySQL. I have three table, each has foreign key relationship. Three fields of TitleOrder table are gt1,gt2 and gt3 which are indicating p1,p2 and p3 of Percentage table respectively. I need each data of TitleOrder and Percentage should be one by one in correct […]

Merge multi data sources to sink and keep up to date

Query asked by user My business has many tables in different MySQL instances, now we want to build a searching platform. So we have to extract and join them to a width column table, insert them to elastic search, and keep them up to date in es. In addition, We have an application that converts […]

SQL Removing Milliseconds from a SQL query

Query asked by user My Query is: SELECT Symbol, SEC_TO_TIME(AVG(TIME_TO_SEC(High_Time))) as AvgTime FROM data GROUP BY Symbol; Output: Symbol AvgTime AAPL 03:34:00.0000 TSLA 10:50:00.0000 SHOP 03:40:00.0000 How would you change the query so the output looks like this? Symbol AvgTime AAPL 03:34:00 TSLA 10:50:00 SHOP 03:40:00 Solution You could simply apply the ROUND function on […]