Skip to content

Tag: mysql

SELECT statement across multiple tables

First off, I am not an SQL coder. I am trying to select information from 2 different tables in the same database. Table 1 is called trans and has 3 columns: Table 2 is called cust and has multiple columns: The SELECT statement that I’m trying to write will pull data from both tables. I THINK I need to u…

Canonical way to store reciprocal data sql

I got a lot of instances of the same Class. Now these objects can be linked and this link can have a weight. Like in an undirected graph. Now I want to store the relationship between each two objects in my mysql database. Data looks like this I could do create a table with this structure: object1_id | object2…

Multiple dynamic FIND_IN_SET searches

So, I have an array like this in my programming language: And I have a MySQL database table like this: Unfortunately, I cannot change the table to be more relational (yet). I want to pull out how many times an item in my array is present in the database value column. Now, the obvious way to do this would be

How to create procedure in mysql

I am creating a procedure in mysql but I am facing issues with the required result and now I am in a total mess. Please help me! The requirements is this: Get the Top 20 entries from the table, for the current day. By Top 20 entries, they should be the ones that occurred most often during the day –

Quick way to find a word using a SQL query

My current code is to try to find 2 words “Red Table” in Title: The problem is, this is so slow! I even put the status “Index” to the column Title. I just want to search for multiple words in one (I would prefer in title AND description), but obviously I can’t use LIKE because it…

MySQL: Extract Select in “Module”

Assuming the following SQL statement: The there a way to modularize the statement, for instance, extract the second select statement in a file and call this file instead of writing the whole query? Answer I found a way to reuse SQL. Its possible via SQL-Functions and SQL-Procedures