Skip to content
Fix Code Error

Tag: mysql

With Mysql – Return the output of AES_ENCRYPT as string “0x8DBADD…”

July 18, 2021 by Code Error

Posted By: Anonymous In Mysql the function AES_ENCRYPT() returns a hex like: 0x8DBADD32FD0FAB62232104DEB9D56246 How can I return it as string: "0x8DBADD32FD0FAB62232104DEB9D56246" so for example I can right() to remove the first two characters: "0x" I tried CAST but that converts the HEX to string. What I need is the string literal of the Hex Solution …

Continue Reading

How to set interval in useEffect in React Functional Component

July 18, 2021 by Code Error

Posted By: Anonymous import ‘./App.css’; import { useState, useEffect } from ‘react’ import Axios from ‘axios’ function App() { const [list, setList] = useState([]); useEffect(() => { Axios.get(‘http://localhost:3001/getdata’).then((response) => { setList(response.data) }); }) return ( <div className="App"> <div className="container"> {list.map((val, key) => { return <div className="row">{val.Tweet}</div> })} </div> </div> );} export default App; The above …

Continue Reading

ERROR 1492 (HY000): For RANGE partitions each partition must be defined

July 18, 2021 by Code Error

Posted By: Anonymous I’m trying to create a partitioned table but I’m getting the error message ERROR 1492 (HY000): For RANGE partitions each partition must be defined Am I missing something here. The query looks like this: CREATE TABLE IF NOT EXISTS logdata ( `timestamp` datetime NOT NULL, `device_id` int(11) NOT NULL, `row_id` int(11) NOT …

Continue Reading

Correct method to create a user on a local mysql instance?

July 18, 2021 by Code Error

Posted By: Anonymous wondering the difference between these two CREATE USER methods. create user ‘greg’@’local’ identified by ‘password952’; or would create user ‘greg’ identified by ‘password952’; suffice? Solution Both of these are testable on a local MySQL installation. Generally speaking, though, the correct way to create a user account with MySQL would be like this: …

Continue Reading

MySQL get ID from a table based on email then create a row in another table using ID and more values

July 18, 2021 by Code Error

Posted By: Anonymous I have two tables users and features: users +—-+—————–+ | id | email | +—-+—————–+ | 1 | [email protected] | | 2 | [email protected] | | 3 | [email protected] | | 4 | [email protected] | | 5 | [email protected] | +—-+—————–+ features +————+———+———————+————+ | feature_id | user_id | feature_name | can_access | …

Continue Reading

Ajax call having Inner Join query in Eloquent Laravel 8 not working

July 17, 2021 by Code Error

Posted By: Anonymous I wanted to fetch data from two tables using inner join in Laravel 8 and show it in front end as datatable by Ajax. But ajax call is returning internal server error. Here is my controller if(request()->ajax()) { return datatables()->of(Machine::select("machine_base.id as id", "machine_base.machine_name as machine_name", "machine_base.machine_category as category_id", "item_category_base.category as category_name")) ->innerJoin("item_category_base", …

Continue Reading

How to get rid of Liquibase includeAll tag with formatted .sql changesets error: Cannot find the declaration of element ‘databaseChangeLog’

July 17, 2021 by Code Error

Posted By: Anonymous I am using a Gradle Spring project with liquibase. To run liquibase I am running the jar created by compiling the project. I am trying to use the liquibase "includeAll" tag in an xml changelog to run all formatted sql changelog scripts inside a directory I’ve called includeAllScriptsTest (currently contains only one …

Continue Reading

How to get the id after fetch call?

July 17, 2021 by Code Error

Posted By: Anonymous I want to target the id by gettng it but I seem to only get the whole data which if I console log it I see id and such but I have no clue how to only print the id in console log Here is an example code: fetch(‘http://localhost:5000/get/’ + f) .then((response) …

Continue Reading

getting records by id and querying there relation with ‘wherebetween’ using Laravel and eloquent

July 17, 2021 by Code Error

Posted By: Anonymous i’m trying to get all measurements from a certain recorder between a certain timespan. If i remove the "->wherebetween()" part of the query and view the results then I get all the sensors of that recorder and all related measurements of that sensor. But I’m not able to execute a wherebetween on …

Continue Reading

How can I get tables which using [DEFAULT CURRENT_TIMESTAMP] in mysql?

July 17, 2021 by Code Error

Posted By: Anonymous Some of my tables are using DEFAULT CURRENT_TIMESTAMP for create_time field in my mysql DB. `create_time` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT ‘data create time’ And I want to select all my tables which use DEFAULT CURRENT_TIMESTAMP. How can I make it? Solution SELECT TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_DEFAULT = ‘CURRENT_TIMESTAMP’ …

Continue Reading

How did mysql workbench get my old database?

July 17, 2021 by Code Error

Posted By: Anonymous I created database using mysql from phpmyadmin for some practice purposes. Now I’ve just downloaded and set up mysql workbench and right after I saw my old database which I created in phpmyadmin and that makes me wonder how did workbench get it? Solution Both phpMyAdmin and MySQL Workbench are administration/client tools. …

Continue Reading

Equal to operation not working on a field with updated collation

July 16, 2021 by Code Error

Posted By: Anonymous I was trying to convert an existing varchar column with a unique index on it to a case sensitive column. So to do this, I updated the collation of the particular column. Previous value: utf8mb4_unicode_ci Current value: utf8mb4_bin Now I have a row in my table TEST_TABLE with test_column value is abcd. …

Continue Reading

MySQL LAG/LEAD issue

July 16, 2021 by Code Error

Posted By: Anonymous I am trying to move some code from my current host to GoDaddy and am having issues with LEAD/LAG. I have the following SQL statement in my code: SELECT id, LAG(Clients.id,1) OVER w AS ‘lag’, LEAD(Clients.id,1) OVER w AS ‘lead’ FROM Clients WHERE custno IS NOT NULL WINDOW w AS (ORDER BY …

Continue Reading

How can I make my sql trigger about inappropiate words work

July 16, 2021 by Code Error

Posted By: Anonymous I have a database with different tables in order to store photos, users, reviews, ratings… I wanna validate that no one uses "bad words" (insults) in their photos’ title or description. So I decided to create a table called ‘inappropiatewords’ where all of these bad words will be stored and then I …

Continue Reading

How to extract and flatten and array that is inside of JSON objects in MySQL 8?

July 16, 2021 by Code Error

Posted By: Anonymous Given some json documents like this: { "_id":"00006073", "subscribersIds":[ 170968, 225647 ] } ———————————– { "_id":"00006072", "subscribersIds":[ 170968 ] } ——————————– { "_id":"00006074, "subscribersIds":[ 228195, 225647 ] } Do you know how can I get a list of the subscribersIds, without repetition? The result should be something like this 170968, 225647, 228195, …

Continue Reading

LEFT() function extracts a number of characters from a string inside where

July 16, 2021 by Code Error

Posted By: Anonymous How can build this query? In the documentation I didn’t find any reference to the LEFT function 🙁 SELECT * FROM Customers WHERE LEFT(CustomerName, 2) = ‘An’; to: await Customers.findOne({ where: { [fn(‘left’, col(‘CustomerName’), 2)]: ‘An’ } }); Any idea? Solution I think you can do: await Customers.findOne({ where: { CustomerName: { …

Continue Reading

Mysql order by field with given values which has NULL in between

July 16, 2021 by Code Error

Posted By: Anonymous I’m trying to sort a query by given values like this: ORDER BY FIELD(items.stock_id, 1, 5, NULL, 3, 6) But it seems it doesn’t work and null comes first or last depending on it being descending or not. The order is not always the same hence [1,5,NULL,3,6] changes every time and is …

Continue Reading

optionally enclosed not working, commas breaking upload

July 15, 2021 by Code Error

Posted By: Anonymous I have this table: CREATE TABLE my_table( trans_id INT NOT NULL AUTO_INCREMENT, spend decimal(10,2), impressions int, PRIMARY KEY (trans_id) ); Here is my load statement: LOAD DATA LOCAL INFILE ‘C:/ProgramData/MySQL/MySQL Server 8.0/Uploads/my_file.csv’ INTO TABLE my_table FIELDS TERMINATED BY ‘,’ OPTIONALLY ENCLOSED BY ‘"’ LINES TERMINATED BY ‘rn’ IGNORE 1 ROWS (spend, impressions); …

Continue Reading

Pending request on Django

July 15, 2021 by Code Error

Posted By: Anonymous I’m building a website using Django. I have the register and login sessions working, so any user can create an account and login. But now I want a situation whereby when someone creates an account, the account will be inactive and pending until the admin accepts the user. However, I haven’t implemented …

Continue Reading

Insert Excel datas on mysql with php

July 15, 2021 by Code Error

Posted By: Anonymous I’m trying to insert excel datas in mysql with php, I have a code but it’s inserting only the first line off the archive and my archive has 3 lines. Someone knows how to help me? public function incluirLote() { if (!empty($_FILES[‘arquivo’][‘tmp_name’])) { $arquivo = new DOMDocument; $arquivo->load($_FILES[‘arquivo’][‘tmp_name’]); $linhas = $arquivo->getElementsByTagName("Row"); $countlinha …

Continue Reading

OQL and SQL queries. Select all department numbers whose employees have the same salary

July 15, 2021 by Code Error

Posted By: Anonymous So, I have two tables: EMP {EMP_NO, EMP_SALARY, EMP_DEPT_NO} DEPT {DEPT_NO, DEPT_MNG} EMP_NO, DEPT_NO – primary keys, EMP_DEPT_NO – external key to DEPT, DEPT_MNG – external key to EMP. I need to find all departments where every employee has the same salary. Solution You can use the COUNT DISTINCT in the HAVING …

Continue Reading

mysql rename column output query

July 15, 2021 by Code Error

Posted By: Anonymous mysql rename column output query Hey guys! I’m trying to create a kind of alias to use as a variable in grafana but I’m not getting the desired result… My intention is that the query returns only the alias created from the query and not the name of the column itself. See …

Continue Reading

trouble shoot a creating a mySQL function for parsing a string

July 15, 2021 by Code Error

Posted By: Anonymous I’m getting a SYNTAX error attempting to create a mySQL function to parse a string. It’s probably something simple that I’m not realizing given that I have more experience creating FN’s with SQL then MySQL. Here’s my function: CREATE FUNCTION fn_parse_string (string1 varchar(2048),datapoint1 varchar(20),delimiter1 varchar(1)) RETURNS varchar(60) DETERMINISTIC BEGIN DECLARE datareturn1 VARCHAR(60) …

Continue Reading

How to use temporary table in the from clause in mysql?

July 15, 2021 by Code Error

Posted By: Anonymous I am trying to write a query to get the designation which has got the highest and second lowest amount (salary + variables) for the whole year of 2019 along with the corresponding amount values. Employees Table: | Emp_id | first_name | Last_name | Salary | Joining_date | Department| |:—— |:———-:|:———:|:——:|:—————–:|:———:| | …

Continue Reading

MySQL: Conditional Trigger

July 15, 2021 by Code Error

Posted By: Anonymous Is it possible to create a trigger that conditionally updates a column with a random value from another tables column. Previously I received help to create a trigger that updates a column with a random value from another tables column: MySQL: Trigger Update with random value from another tables column. I’m trying …

Continue Reading

MySQL: FKs to non-unique column

July 15, 2021 by Code Error

Posted By: Anonymous As I found out to my surprise MySQL allows FKs to non-unique columns. I am not sure if this applies to other databases as well and always thought the FK had to be unique – otherwise, how do we know the parent row of a child – but looks like that is …

Continue Reading

SQL create a column based on Groupby condition

July 14, 2021 by Code Error

Posted By: Anonymous I’m trying to see if an event appears more than once in a table within a month and assign a boolean logic 0 for ‘No’ and 1 for ‘Yes’. Example table: Event Event date Turn 2021-01-24 Turn 2021-01-25 Turn 2021-03-14 Turn 2021-04-21 Stop 2020-05-20 Stop 2021-05-20 Stop 2021-05-24 Start 2021-05-23 Start 2021-05-24 …

Continue Reading

HQL Responding with org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: u

July 14, 2021 by Code Error

Posted By: Anonymous I am trying to get a list of all the users in my system Using HQL and it throws me error org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: u here is my method Where I am trying to fetch all the users from DB I am using Mysql as database please have a look and let …

Continue Reading

How to perform couple of mysqli queries and add one result into existing result array?

July 14, 2021 by Code Error

Posted By: Anonymous Need to perform couple of mysqli queries and add one result into existing result array, currently I have implemented first query, $dataQuery = "SELECT * FROM movies_table"; $sth = mysqli_query($conn, $dataQuery); $rows = array(); while($r = mysqli_fetch_assoc($sth)) { $rows[] = $r; } $respObj->status = ‘success’; $respObj->movies = $rows; $respJSON = json_encode($respObj); print …

Continue Reading

Current month datetime count in mysql

July 14, 2021 by Code Error

Posted By: Anonymous I want the current month date count in MySQL query not related to any table. like, Current month: June count: 30 (days in the month) how to do without any relationship with table ??? Solution You can use last_day() to get the last day of the month. And then day() to extract …

Continue Reading

Posts navigation

  • 1
  • 2
  • 3
  • 4
  • …
  • 54
  • Next

.net ajax android angular arrays aurelia backbone.js bash c++ css dataframe ember-data ember.js excel git html ios java javascript jquery json laravel linux list mysql next.js node.js pandas php polymer polymer-1.0 python python-3.x r reactjs regex sql sql-server string svelte typescript vue-component vue.js vuejs2 vuetify.js

  • you shouldn’t need to use z-index
  • No column in target database, but getting “The schema update is terminating because data loss might occur”
  • Angular – expected call-signature: ‘changePassword’ to have a typedeftslint(typedef)
  • trying to implement NativeAdFactory imports deprecated method by default in flutter java project
  • What should I use to get an attribute out of my foreign table in Laravel?
© 2022 Fix Code Error