Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Questions tagged [mysql]

MySQL is an open-source, relational database management system. If your PHP code uses MySQLi, use the MySQLi tag instead.

Filter by
Sorted by
Tagged with
7
votes
3answers
1k views

CRUD operations for a contact list using PyMySQL

I am from Java background, learning Python. Please review my code and guide me to learn Python properly. This is a sample code to perform all CRUD operations of contact app. ...
2
votes
1answer
75 views

Insert contact information from form fields into MySQL database when button is clicked

I am just a beginner trying to do my due diligence and research things properly. I am trying to go about the correct way of adding data into a database. I have read articles on the following: Not ...
0
votes
1answer
40 views

MySQL CLI: Create a MySQL user & DB

Please review my Bash code to create an authenticated, all privileged MySQL user plus a DB with the same name, through the MySQL CLI: ...
1
vote
2answers
64 views

SQL to find users that the current user hasn't liked/disliked

I have this really long query, which in my opinion looks ugly next to all the tidy code in my project. I was wondering if there was a way to optimize it or make it shorter at least: ...
4
votes
1answer
1k views

Runs a MySQL query, returns Dictionary<string, string> or false;

I've been practicing C# and ASP.NET, and have been working on a somewhat larger-scale project than I am currently used to. I am sure there are horrible things wrong with this code that I will find out ...
0
votes
2answers
74 views

Method Calculate User Answers

I am writing spring hibernate app to make online test and this method for calculating user grade I have one to many relations between multi-choice question and answer. Also, please check this ...
1
vote
1answer
666 views

Query Select and Insert if not exists

Are there any good ways to make this createIndexBlock() method shorter? It looks wastefully long. I have many tables. I don't like to make these kinds of methods. ...
3
votes
1answer
100 views

MySQL request in Python

In my code I have three requests to a MySQL database: ...
2
votes
1answer
1k views

Calculate the total price of products for each store

I have an application that take the user location, check which store sell on that location and then calculate the total price for the products the user selected on the shopping cart. For example, if ...
0
votes
1answer
76 views

Counting first letter of title and printing letters from a to z

I am trying to count the titles according to the first letter and filter it by the tag. I tried for ages and I am not sure if I can write this query in a better way. Can you please advise me. Here ...
2
votes
0answers
277 views

Query your MySQL server for table size by row count and physical size by database

After writing a similar SQL procedure to check my table sizes several times, I wrote this stored procedure to check my MySQL database's table size. It will show you the table sizes and row count ...
1
vote
1answer
1k views

PHP PDO Class with multiple Select Efficiency and speed [closed]

I am very new to classes, and not sure how efficient this class is, would appreciate improvement feedback and info on efficiency including speed. The class includes a construct that creates a ...
2
votes
1answer
283 views

Single MySQL Query one-to-many efficiency

I am fairly inexperienced with the ramifications of doing a single select where joining several tables and there are several one-to-many relationships while also running some built in MySQL functions ...
1
vote
0answers
38 views

Analyze the image of the database relation and create the original database

I've sorted out an image relational database, and created its original database in phpmyadmin (I use XAMPP). Here is a picture of the database relation: This is a database image I created myself in ...
1
vote
1answer
23 views

Classifying counts of repeat visits per user for a website

I am trying to get number of times (or sessions) a user re-visited the website. What I'm trying to find out- Get the total number of users, number of sessions in the last 30days. I need to a pie ...
1
vote
1answer
56 views

Simulating a hospital

I have a Java program which simulates a hospital. For this, I have two different databases, MySql and MS SQL, with tables to manage the patients. The user can decide which database he wants to use. ...
2
votes
2answers
7k views

Mysql multiple queries from one PHP file

I'm running the below code to populate a HTML table using several calls to mysqli_query(). The below snippet only shows three however I'm running ten in my file for ...
2
votes
1answer
64 views

MySQL Connection URI Regular Expression

I'm currently working on a project that involves a MySQL database. To make life a little easier, I've been working on a regex that should validate and pull apart the different sections of the ...
1
vote
0answers
195 views

Replacing a substring in a table

I am using DB::table to search through a table that has a field called 'data' that has a substring ...
2
votes
0answers
42 views

Optimising code for performance Concrete5/PHP/MySQL

I am trying to be as efficient as a I can using a CSV to import users to a CMS called "Concrete5 - Version 8.2.1". I have a list of 700+ users and i've created an upload screen to take in a CSV and ...
9
votes
1answer
198 views

Creating a Perl webserver

Intro Finally had the time to do some wargames again, but I have come to the point where I need to build my own test enviroment to test certain ideas, because I can't test it online. The current ...
1
vote
2answers
255 views

PHP PDO statements

I wrote a piece of code. and to be honest it seems a bit messy so I would like some opinions on it, and if I can make it cleaner. Or if there are better ways to do it: ...
1
vote
1answer
44 views

MySQL query to select number of fields occurring more times than x

I want to find out the 'rank' of a word in any given language. A word with a rank of 1 means it's the most commonly used word in the language. There are two MySQL ...
3
votes
1answer
949 views

Optimize cURL requests to Google API

I have a table in MySQL with approx. 20 million rows and the following columns: id | word_eng | word_indic I have to translate the English word (the value in ...
1
vote
0answers
3k views

Using async/await with Node.JS MySQL

Is this the right way to use async/await with the JavaScript MySQL client? I had to use the promise-mysql package because it wraps the function calls with Bluebird promises, so that I'm able to use ...
1
vote
2answers
541 views

Router for quering MySQL results in NodeJS

What should I consider in order to refactor the following code ? It seems very close to proudly become a Pyramid of Doom: ...
3
votes
1answer
141 views

Finding sessions associated with an IP address using PDO

Originally Posted on Stack Overflow First of all I want to say that I'm new to PDO. I did tried it once but since I found the oop solution complicated and even impossible (...
1
vote
0answers
258 views

Connecting MySQL with connection pool in NodeJS

I'm trying to connect to a MySQL database in NodeJS. It seems it is creating multiple pool connections from multiple sources, instead of using the old one. If I try this in MySQL console: ...
2
votes
1answer
70 views

Bash script to validate a MySQL database

I am fairly new to bash script programming so I would love some feedback. I am trying to write a series of migration scripts for our DBs (please don't direct me to other tools; I spent a lot of time ...
4
votes
1answer
80 views

Performing substitutions according to a word list in a database

A bit of history I had about 40,000 words in the database. I need words to correct the texts entered incorrectly by users. User enter text in any non-legal format and I use my words in the database ...
2
votes
0answers
58 views

I wrote some import functions from APIs for a large scale application

I run a large scaled app much larger than I can handle or develop for, website grew out of control and currently has over 22000 users. We support importing from different APIs, each import is split ...
3
votes
0answers
82 views

PHP Laravel function to search for ads in MySQL

I am new to the Laravel framework. I have recently written a function which gets called through a route. The function is created for two purposes: Get ads from a particular city based on provided ...
6
votes
3answers
22k views

Shortest and longest city name and alphabetical order

Problem Query the two cities in STATION with the shortest and longest CITY names, as well as their respective lengths (i.e.: number of characters in the name). If there is more than one ...
3
votes
0answers
172 views

Database check in a loop

I have a python script that loads a database table and checks an API for the entries found. I do it like this: ...
3
votes
2answers
437 views

Getting database values grouped in an array

I have a database column with dates corresponding to sales orders. I get the count of orders in each month. Currently in my code, I use a switch statement. I know ...
1
vote
0answers
621 views

Mysql Stored Procedure: group_concat with group by, and then all combinations of elements in csv

Problem So what problem am I trying to solve? Given that we have a list of IDstrings, with an associated region, I want to produce all the different combinations of IDStrings possible for a specific ...
1
vote
0answers
2k views

MySQL structure and normalization for real estate agency database

What I'm trying to achieve is to create a site for a real estate agency, which has the responsibility to sell or rent someone else's property. I'm not sure how far from correct what I've created is. I ...
1
vote
2answers
14k views

Displaying MySQL table data using Node.js

I'm trying Node.js for the first time, everything works, but i'm not sure that my approach is right, can you tell me if it's ok? In this test, i've tried to get ...
1
vote
2answers
944 views

Custom PDO wrapper class

I somewhat recently asked a question on here for advice on a PDO function that I had written. I got some good advice from a user, and went with it. I had used that function for about 3 months which is ...
5
votes
1answer
115 views

Automatic database migration system

Github here: https://github.com/cmancone/mygrations I'm working on a different kind of database migration system for helping manage web applications. I asked a question about part of the system just ...
1
vote
1answer
1k views

Separate areacode from phone number string with MySQL Database

I have a database with 5000 entries of local area codes to separate the area code from a phone number string. I'm not sure if the code I use is the fastest way to solve these job. I shrink the ...
5
votes
1answer
84 views

Resolving MySQL 1215 errors in a declarative MySQL migration system

Github here: https://github.com/cmancone/mygrations I'm building a migration system for MySQL that operates in a very different way than the usual. Rather than recording changes in the database, the ...
2
votes
1answer
152 views

Plugin for showing cross-sells on the single product page in WooCommerce

I made a custom plugin for showing cross-sells on the single product page in WooCommerce, however i need to know if this is secure and possibly act as an attack vector. Additionally, is there a better ...
2
votes
0answers
53 views

Joins on same table with MAX()/MIN() and corresponding fileds

I made a query for showing max and min value and dates that are corresponding to those MAXs and MINs. The idea was to show max/min value and the date when the those values occurred in one row for ...
1
vote
0answers
291 views

Django Rest Framework model relations for a Gallery app

I'm creating a school project, a Gallery app. I have the following entities: Profile, Album, ...
1
vote
0answers
87 views

Printshop database design

I am trying to design multi purpose printshop database on which I will develop my basic store system. Beofre I tried to design it using EVL (Entity-Attribute-Value) aproach, however some users would ...
8
votes
1answer
149 views

A PHP API which has an endpoint for processing a user's facebook login details

I'm working on a PHP API for my angular JS Phonegap application. At the moment I'm focusing on working with a user's facebook public profile data. I'll explain the process a little first: The user ...
0
votes
1answer
100 views

PHP fighting system

I'm a young beginner in PHP and all. I'm just trying to make a fun game while learning by myself so you will easily spot errors. The code is working, yet it need some serious improvements as this is ...
1
vote
0answers
99 views

Getting data from a server for raffle game and saving data back to the server

So I'm making a raffle game so when you press B you get a random name with all the information of the winner. I get the data from a local SQL server and I want to make a list of the winners by saving ...
1
vote
1answer
43 views

Listing blog posts, each of which may belong to multiple categories

I have 3 tables like this: ...