MySQL is an open-source, relational database management system.

learn more… | top users | synonyms

3
votes
1answer
61 views

Managing “Jobs” data in a Database

I've been working in a small page with some easy CRUD. The data I get from the database is getting shown on the page. But the way how i show the data feels a bit off. I guess it can be done in a much ...
2
votes
1answer
20 views

Query of attributes of mobile phone models, using several UNIONs to find distinct values

I'd like to know if there's any room to improve the following query which is to find distinct values from multiple tables when someone searches for a model name. Two of the tables are storing phones' ...
1
vote
1answer
36 views

Obtaining weather station data from a MySQL database

I have a PHP page for a weather station that I'm trying to build. I run multiple queries to pull out data from a MySQL database for min/max/average values for temp, pressure, humidity etc. All of ...
1
vote
1answer
17 views

MySQL proliferation of subqueries and left joins

I have the following query: ...
1
vote
1answer
28 views

Loop through post and use in query

so i'm using a foreach loop to loop through a form i've send with javascript. In this loop I use the keys(input fields names) and values(input values) and use them to build my query, I still check for ...
1
vote
1answer
16 views

Weighting mysql full-text search results by date

I'm using innodb full-text search to return a set of results where the newest posts are more relevant. Just wanted to check that this the best method: ...
6
votes
1answer
57 views

Database of students in a social network

This is sourced from the Stanford Coursera self study DB class SQL quizzes. Students at your hometown high school have decided to organize their social network using databases. So far, they have ...
2
votes
2answers
87 views

Spreading MySQL query code over multiple lines - new lines vs concatenation

Is there any reason NOT to wrap a long query over multiple line via new lines vs using concatenation? For example, consider this: ...
2
votes
0answers
48 views

PHP MySQLi database wrapper

I am developing a mysqli database wrapper. I've made an effort to make this as fast as possible and easy to use. However, now I want to start adding callbacks (for ...
4
votes
2answers
131 views

IMDB website query to find actors by time period

I'm using data from a database from the IMDB website. The database consists of five relevant tables. Actor (id, fname, lname, gender) Movie (id, name, year, rank) Director (id, fname, lname) Cast ...
4
votes
1answer
115 views

MySQL IMDB Query Speed

I'm using data from a database from the IMDB website. The database consists of five relevant tables. Actor (id, fname, lname, gender) Movie (id, name, year, rank) Director (id, fname, lname) Cast ...
2
votes
2answers
153 views

Does this column need to be indexed?

I have the following query which brings back a list of items which fall into a particular category: ...
3
votes
3answers
191 views

SQL delivery query performance

I need a "little" help with an SQL query (MySQL). I have the following tables: COURIERS table: ...
8
votes
2answers
256 views

MySQL class to add user/database

I'm creating tool to add new virtualhost on UNIX-box. One of tasks is to add a new user and database to MariaDB (aka MySQL) server. In fact - this my first 'real' attempt to use OOP. Here is class, ...
10
votes
1answer
187 views

Web application for a restaurant

I'm making a web application for a restaurant kind of type. The idea is to administrate the orders and customers. For selecting one of the orders and showing more specific data about it, I have this ...
5
votes
1answer
76 views

PDO Login/Register system I've been working on

I'm relatively new to PHP and programming as whole. I'm sure my code could be better in a lot of ways, most of which I can't fully grasp at the moment. As it stands I'm trying to avoid the general ...
4
votes
2answers
77 views

Simple login system

I'm pretty new to PHP and programming general so I'm quite sure my code is an absolute mess. My goal is to write good code, that others can understand just by looking at it. This is a simple login ...
11
votes
6answers
490 views

Efficiency with strcpy, strcat and malloc

I'm still learning C, but I'm trying to make sure I've got a decent grasp on working with "strings" and data structures. If possible, I'd like a little input on how I'm handling this and see if it ...
2
votes
2answers
76 views

Optimizing nested “Select Distinct” query

I am using the following query which is causing issues. Note following points: I am using 4 tables in this query: message_share ...
3
votes
3answers
191 views

A child ID getting all parent IDs

Is there any MySQL function that will optimize this code? ...
4
votes
1answer
59 views

Random select in two MySQL tables

I wrote a simple AJAX request that performs a random select in two MySQL tables. The thing is, my current script involves connecting to the database and creating a new PDO every time the ...
3
votes
1answer
52 views

Inserting data in 3 tables of a database with JPA

I am starting a personal project and my first step is to insert a lot of statuses from tweeter in a database along with it's user and place (if applicable). This is the database structure: Pretty ...
4
votes
3answers
101 views

SQL design for representing a two-level hierarchy of objects with containment

I am trying to represent questions in quizzes. The database is Mysql but I am using fairly generic sql. The assumption is that varchar cannot handle more than 255 though, so I am supporting longer ...
2
votes
3answers
260 views

Check if URL contains different strings

The code it self is pretty self explanatory, however i do not think it is very efficient at all. Is there a better way to do this? Its basically so i can track spam sites and save the sites into my ...
3
votes
1answer
29 views

MySQL SELECT from two tables with different situations

I'm trying to select two groups of countries with different situations. ...
4
votes
1answer
114 views

Extendable PDO Wrapper Class

I've created a PDO wrapper. I understand PDO could be used on it's own, and I'm reinventing the wheel as there are solutions like Laravel's Eloquent that would do a better job. I'd like advice on ...
5
votes
3answers
238 views

Extracting certain records

The purpose of this SQL query would be to extract the record 10192 only, because the end_time is both in the past and its foreign counterpart in the Node table ...
7
votes
3answers
291 views

MySQL update with PHP; MySQLi prepared statement in loop

I'm going to develop an Android application that performs simple MySQL operations by invoking server-sided PHP scripts. PHP-MySQL communication is done by MySQLi extension. Each operation that I'd ...
5
votes
1answer
45 views

I think I should use JOIN but I did this instead

Let me start by saying that I am brand new to PHP and MySQL. I have two tables. One table is called domains and it contains the "rep" column which is an integer. It is related to the column "id" in ...
6
votes
2answers
157 views

Database layer class

I'm trying to get familiar with database handling. Can you point out my errors and what I should change? I want to learn new methods, but just don't want to learn it the wrong way. I do realize ...
8
votes
4answers
962 views

Inserting 1 line into my SQL database

This is for adding code into my table really easily, however it will be called 2000+ times per second, so I need to know if this is the most efficient code to add a row to the database. ...
4
votes
3answers
91 views

Web application to insert into MySQL database

I'm currently learning PHP, SQL/MySQL and HTML to develop a web application project (I have very little practical experience in all of these.) To get started, I spent far too long and many questions ...
10
votes
1answer
94 views

Abusing Excel VBA… to maintain data stored in a database

I need to build a little UI to allow easy maintenance of some data stored in a MySQL database, and the end user wants to do that in Excel (I know, I know). The code I came up with comes pretty close ...
4
votes
2answers
53 views

Multiple dependent subqueries

This query currently takes approximately 250 seconds to run and I'd like to reduce it by as much as I can. I have tried using left joins instead of subqueries and it increases run time. ...
11
votes
2answers
574 views

PHP URL Shortener

I just developed a URL shortener. index.php: ...
5
votes
1answer
48 views

Library database search with multiple JOINs is too slow

I have a MySQL query which runs very slowly. I've rewritten it many times but no improvements yet. My current query for advanced search takes about 60 secs to complete. Any suggestions for improving ...
7
votes
3answers
158 views

Getting the top 10 stores within a category

I have the following query. I know there's an easier way to do this without the sub queries, or at least optimizing how they're used. I've read about cross joins and using ...
7
votes
2answers
537 views

Protect database from SQL Injection and similar attacks - PHP

I am doubtful about the security of my PHP code. I am new to programming, but want to learn how to secure things, protect my databases from SQL injection, and other best practices. I'd like to know if ...
6
votes
3answers
472 views

Check efficiency of PHP code that will query over 8500 orders

I am querying all orders from a WordPress database that uses the WooCommerce Bookings plugin. I want to display upcoming bookings, and there is a potential to have every hour within 2015 to be booked; ...
5
votes
2answers
209 views

DB abstraction, private methods in OOP PHP library

This library registers a new user. Questions: Where should the DB class instantiation happen for user class? I tried instantiation in the constructor but that property doesn't seem to be available ...
4
votes
1answer
75 views

Refactoring of this complex PHP method

I have one complex method with 1890 paths. I don't know how can be this refactored. Can somebody add some tips about it? Maybe the MySQL table structure is wrong. ...
12
votes
2answers
83 views

Revision 1 - Step 1: PsychoProductions management tool project

I started a project to build my own invoicing and management system to take the place of prohibitively expensive QuickBooks software. This will be broken down in 5 steps, with the current step in bold ...
6
votes
5answers
567 views

Username, Password and UserType Validation

I have two tables in the database: Credentials (userid, password, usertype) Customer ...
4
votes
4answers
512 views

Two while for the same query

If I have to loop results of a query echoing first all fields of a column, then echoing something not to loop, then fields of another column. ...
2
votes
1answer
19 views

Query the Max Nth per group

I'm trying to write the most efficient query I can to pull the relevant data I need for retrieving the latest conversations for a user, ordering groupings of conversations by most recent message in ...
8
votes
1answer
56 views

Step 1: PsychoProductions management tool project

I started a project to build my own invoicing and management system to take the place of prohibitively expensive QuickBooks software. This will be broken down in 5 steps, with the current step in bold ...
2
votes
1answer
78 views

UserDAO with CRUD functionality for my UserRepository

This is my first attempt at creating a DAO. I would like to get some feedback regarding the following aspects if possible: Code readability Efficiency Usability I also would appreciate any other ...
3
votes
2answers
286 views

Dynamically load data into bootstrap accordion navigation bar

I have made a bootstrap accordion navigation bar that loads data dynamically from a database with PHP. Here are the two tables that I use: ...
8
votes
3answers
118 views

Would this be an efficient way to use MySQL?

I've recently learned how to use MySQL to store/retrieve data. I've created a MySQLManager class for creating connections and executing querys/updates. Would this be an efficient way to do so? This ...
5
votes
1answer
59 views

Conditional row count across 4 tables

I have the following function that works fine. Is there a better way to do it and will this be efficient if I have 100+ rows returned from each table? The database Tables ...